IT 취미생활.  
Front Page
Tag | Location | Media | Guestbook | Admin   
 
'Programming'에 해당하는 글(80)
2008.10.16   [알고리즘] BubbleSort
2008.10.10   [Windows Mobile] Windows Mobile 6 SDK 종류
2008.09.01   [C++]asio C++ library
2008.08.27   [Wince5.0]Platform build 에서 cmd 창으로 부분 빌드하기
2008.08.18   Little-Endian to Big-Endian
2008.08.12   [Wince5.0] Debug Mode에서만 출력하는 디버깅 메시지
2008.08.04   [Wince5.0] VS2005 배포시 여러 파일을 같이 배포하기
2008.08.04   [Error Case - Wince5.0]fatal error LNK1112: module machine type 'ARM' conflicts with target machine type 'X86' 2
2008.08.04   [Error Case - Wince5.0] C4430
2008.07.31   Windows Mobile 6.0과 Wince 5.0 2
2008.07.21   [알고리즘]힙(heap)을 이용한 우선순위 큐 1


[알고리즘] BubbleSort

간단하게 Bubble Sort을 만들어 보았습니다.

정렬 방식은 Buffer 마지막에 가장 큰 값을 옮겨두고, 첫 번째 for loop의 index를 -- 하여
뒤에서 부터 큰 값들이 정렬되도록 하는 sorting 방법입니다.
알고리즘 효율은 O(N^2) 입니다.

Function 이름은 "한눈에 보이는 C 알고리즘"이라는 책에서 가져다 사용 했습니다. - 귀차니즘

프로그래밍의 왕도는 역시 불여일타!!!!





#include <cstdlib>
#include <iostream>

using namespace std;


#define MAX_SIZE 100

int NumberExit( int *_arrayBuffer, int _number, int _index)
{
    for( int i=1 ; i < _index; i++ )
    {
            if( _arrayBuffer[i] == _number )
            {
                return true;
            }
    }
    return false;
}

void MakeRendomNumber( int *_arrayBuffer )
{
     int nNum = 0;
     srand( (unsigned)time( NULL ) );
     _arrayBuffer[0] = MAX_SIZE;
     int i = 1;
     while( i < MAX_SIZE )
     {
            nNum = rand() % MAX_SIZE;
            if( false == NumberExit( _arrayBuffer, nNum, i ))
            {
                _arrayBuffer[i] = nNum;
                i++;
            }
     }
}

void DisplayBuffer( int *_arrayBuffer )
{
     for( int i = 0; i < MAX_SIZE; i ++ )
     {
          if( (i % 10) == 0 )
          {
              cout << "\n";
          }
          cout << _arrayBuffer[i] << "\t";
     }
     cout << "\n";
}


 

void BubbleSort( int *_arrayBuffer, const unsigned int _arraySize )
{
     for( int i = _arraySize - 1; i >= 0; i-- )
     {
          for( int j = 1; j <= i ; j++ )
          {
               if( _arrayBuffer[ j - 1 ] > _arrayBuffer[ j ] )
               {
                   int nDummy  = _arrayBuffer[ j - 1 ];
                   _arrayBuffer[ j - 1 ] = _arrayBuffer[ j ];
                   _arrayBuffer[ j ] = nDummy;
               }
          }
     }
}

int main(int argc, char *argv[])
{
    int Buffer[ MAX_SIZE ] = { 0 };
   
    MakeRendomNumber( Buffer );
    DisplayBuffer( Buffer );
    cout << "\n";
   
    BubbleSort( Buffer, MAX_SIZE );
    cout << "\n";
    DisplayBuffer( Buffer );
   
    system("PAUSE");
       
    return EXIT_SUCCESS;
}



[Windows Mobile] Windows Mobile 6 SDK 종류

Windows Mobile 6에서 개발을 하기 위해서 기본적으로 SDK를 설치 해야 합니다.

우선 , Wince 5.0 standard 에서 Build한 Filter는 platform 호환이 되어
그냥 사용 할 수 있었습니다. Application도 또한 바로 Build 및 실행이 되었습니다.

그래도 Windows Mobile에서 사용하는  API를 사용하기 위해서는
해당 SDK를 설치 하여야 합니다.

아래를 참고 하시면 어떤 SDK를 사용 할지 알 수 있습니다.



Windows Mobile 6 Professional and Standard Software Development Kits Refresh

Brief Description
The Windows Mobile 6 SDK Refresh adds documentation, sample code, header and library files, emulator images and tools to Visual Studio that let you build applications for Windows Mobile 6.

On This Page

Quick Details
Version: 6
Date Published: 5/1/2007
Language: English
Download Size: 150.6 MB - 1204.1 MB*
*Download size depends on selected download components.

Overview

The Windows Mobile 6 SDKs add documentation, sample code, header and library files, emulator images and tools to Visual Studio that let you build applications for Windows Mobile 6.

With Windows Mobile 6, we are revising our SKU taxonomy and naming to better align our brand and products with the realities of today’s mobile device marketplace. The historical form-factor based distinction between Windows Mobile powered Smartphone and Windows Mobile powered Pocket PC Phone Edition is blurring dramatically. We want our taxonomies and terminology to evolve to better reflect the evolution of the mobile device industry.

The list below summarizes the changes and the SDK that must be used when targeting the platforms (Previous Categories = New Categories):

  • Windows Mobile for Smartphone = Windows Mobile Standard (download the Windows Mobile 6 Standard SDK)

  • Windows Mobile for Pocket PC = Windows Mobile Classic (download the Windows Mobile 6 Professional SDK)

  • Windows Mobile for Pocket PC Phone Edition = Windows Mobile Professional (download the Windows Mobile 6 Professional SDK)


The Windows Mobile 6 SDKs reflect these changes in the naming of "Project Templates" and "Emulator Images".

The following emulator images are included in the SDKs:

  • Windows Mobile 6 Standard SDK
    • Windows Mobile 6 Standard (176x220 pixels - 96 dpi)
    • Windows Mobile 6 Standard Landscape QVGA (240x320 pixels - 131 dpi)
    • Windows Mobile 6 Standard QVGA (320x240 pixels - 131 dpi)
  • Windows Mobile 6 Professional SDK
    • Windows Mobile 6 Classic (240x320 pixels - 96 dpi)
    • Windows Mobile 6 Professional (240x320 pixels - 96 dpi)
    • Windows Mobile 6 Professional Square (240x240 pixels - 96 dpi)
    • Windows Mobile 6 Professional Square QVGA (320x320 pixels - 128 dpi)
    • Windows Mobile 6 Professional Square VGA (480x480 pixels - 192 dpi)
    • Windows Mobile 6 Professional VGA (480x640 pixels - 192 dpi)

 Top of page

System Requirements

  • Supported Operating Systems: Windows Server 2003 Service Pack 2; Windows Vista; Windows XP Service Pack 2
The following software is required. Please check each application's system requirements individually.

Windows Server 2003
Windows XP
Windows Vista

Important: "Visual C++ Smart Device Programmability", which is an option of Microsoft Visual Studio 2005 Setup, must be selected and installed during Visual Studio 2005 installation.

 Top of page

Instructions

Uninstall previous versions of the Windows Mobile 6 SDK before installing the SDK Refresh.

  1. Click on the buttons below on this page to start the download
  2. Do one of the following:
    • To start the installation immediately, click Run.
    • To save the download to your computer for installation at a later time, click Save.
    • To cancel the installation, click Cancel.

 Top of page

Additional Information


  • Windows Mobile 6 Professional SDK Refresh does not contain the Windows Mobile Standard SDK Refresh and you will need to download both to target both platforms.
  • Windows Mobile 6 Professional SDK Refresh contains Windows Mobile 6 Professional emulator images and one Windows Mobile 6 Classic emulator image.


Known Issues:
  1. Uninstalling one of the SDKs may remove the Cellular Emulator shortcut from the Start Menu. Repairing the installed SDK will re-create the shortcut.

    from : http://www.microsoft.com/downloads/details.aspx?familyid=06111a3a-a651-4745-88ef-3d48091a390b&displaylang=en



 



[C++]asio C++ library
크로스 플렛폼 C++ 라이브러리로써 네트워크와 저수준 I/O를 비동기 모델로 제공한다.


asio is a cross-platform C++ library for network and low-level I/O programming that provides developers with a consistent asynchronous model using a modern C++ approach.

Download
asio - 1.2.0 (Stable)
Last Update: Aug 14 2008



SourceForge.net을 가다 보면 나름 좋은 프로그램들을 만날 수 가 있다.

그럼 고운하루 되세요

 



[Wince5.0]Platform build 에서 cmd 창으로 부분 빌드하기
Platform build 에서 cmd 창으로 부분 빌드하기


set을 눌러서 환경 변수들이 등록이 되었는지 확인을 한다.


cmd 창에서

-------------------------------------------------------------------------------
set WINCEREL = 1   //<-- 환경변수 등록 그럼 rel 폴더로 해당 바이너리가 복사 된다.
cd ...                     // <--- 원하는 폴더로 이동
build -c
makeimg
-------------------------------------------------------------------------------


Little-Endian to Big-Endian

MP4 Decoder에 Video Fream을 넘겨 줄때 앞에 4byte에 Length를 넣으라는
양키의 말에 급조해서 만들긴 했습니다.
더 좋은 코드가 있다면 언제든지 리플과 수정 부탁 드립니다.

UINT my_htonl( UINT nSource )
{
 if( 0 == nSource )
  return 0;

 UINT nResult = 0;
 nResult =  (nSource <<24);
 nResult  =  nResult  | ( 0x00ff0000 & (( nSource << 16) >>8) );
 nResult  =  nResult  | ( 0x0000ff00 & (( nSource << 8) >>16) );
 nResult  =  nResult | ( 0x000000ff & ( nSource >>24 ) );

 return nResult
}




자세히 설명이 나와 있습니다.
아래 링크를 참고 하세요.

http://ssulsamo.egloos.com/3150581


[Wince5.0] Debug Mode에서만 출력하는 디버깅 메시지

Wince5.0이나 WindowsMobile 같은 경우 MFC를 사용하지 않을경우
TRACE를 사용 할 수 없습니다.
따라서 아래처럼 구성해서 사용하시면 DebugMode에서만 동작하는
메시지를 만들 수 있습니다.



#ifdef _DEBUG
#define TRACE                Trace
#else
#define TRACE                ((void)0)
#endif

#ifdef _DEBUG
#define MAX_MSG_SIZE          1024        
void TRACE(const TCHAR *szString, ...)
{
 static TCHAR szBuffer[MAX_MSG_SIZE] = { 0 };
 va_list argptr = NULL;
 va_start( argptr, szString );
 vswprintf( szBuffer, szString, argptr );
 OutputDebugString( szBuffer );
 va_end( argptr );
}
#endif



ex)  TRACE( L"Service Name : %s\n", buffer);
       TRACE( L"WE_SERVICE_DISCOVERY_COMPLETE\n\r " );


고운하루 되세요.


[Wince5.0] VS2005 배포시 여러 파일을 같이 배포하기

회사일이 바빠서 글을 대충 썼습니다.
다시 정리하면...

vs2005를 이용하여, 디버깅 빌드시 배포시 DLL이나 부수적인 파일들을
배포 경로 보내는 구문입니다.

위치는 Property Pages --> Deployment --> Additional Files 에 추가 하면 됩니다.


예)
같이배포할DLL |  DLL이 들어 있는 경로   | 0

DVBT_STR_ENG.dll|$(SolutionDir)/OutPutDlls/Release|ResidentFlash/DvbT Player - Titan|0

ex)

DVBT_STR_ENG.dll|$(SolutionDir)/OutPutDlls/Release|ResidentFlash/DvbT Player - Titan|0
DVBT_STR_DEU.dll|$(SolutionDir)/OutPutDlls/Release|ResidentFlash/DvbT Player - Titan|0
Mpeg2AvPlayer.dll|$(SolutionDir)/OutPutDlls/Release|ResidentFlash/DvbT Player - Titan|0


 



[Error Case - Wince5.0]fatal error LNK1112: module machine type 'ARM' conflicts with target machine type 'X86'
문제 :
VS2005에서 Renderer Filter Compile 시 Error 발생

 I am getting this error message while compiling a SubTitle Renderer Filter code in
VS2005 for Wince5.0 Platform.

fatal error LNK1112: module machine type 'ARM' conflicts with target machine type 'X86'


해결

You can either for compiler to target ARM.To do so Go to Properties->Linker->Advanced->Target Machine. Verify also that in properties->Configuration Type is good because  sometimes between platform switch you can have some pbs.

If you are compiling a resource DLL do not forget to set NO ENTRY POINT
in Linker->Advanced.


Wince Filter 작업을 할때 참고 하세요.


[Error Case - Wince5.0] C4430

오늘도 Builder로 써 열심히 Build를 하고 있었다...
나 <--- 난 거의 팀내 잡부로 수 많은 Link Error를 접해보는 사람이다.

아래와 같은 C4430을 마주했다.

1>.\SubtitlePresentation.cpp(109) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

Class에서 Member Function을 선언하고, 실제 구현부에서 return 값을 빼먹었을때,
C4430이 여지 없이 일어난다 한번 테스트를 해보길...





MSDN Error 페이지를 살펴 보니 아래와 같은 경우 발생하게 된다.

Error Message

missing type specifier - int assumed. Note: C++ does not support default-int

This error can be generated as a result of compiler conformance work that was done for Visual C++ 2005: all declarations must now explicitly specify the type; int is no longer assumed. See Breaking Changes in the Visual C++ 2005 Compiler for more information.

C4430 is always issued as an error. You can turn off this warning with the #pragma warning or /wd; see warning or /w, /Wn, /WX, /Wall, /wln, /wdn, /wen, /won (Warning Level) for more information.

Example

The following sample generates C4430.

  Copy Code
// C4430.cpp
// compile with: /c
struct CMyClass {
   CUndeclared m_myClass;  // C4430
   int m_myClass;  // OK
};

typedef struct {
   POINT();   // C4430
   // try the following line instead
   // int POINT();
   unsigned x;
   unsigned y;
} POINT;



Windows Mobile 6.0과 Wince 5.0

사용자 삽입 이미지


회사에 Windows Mobile 시료가 하나 도착을 해서
Wince 5.0에서 생성한 Filter를 올려보고  샘플 Application도 빌드 해서 올려 보았다.

특별히 Windows Mobile 6.0 SDK를 설치 하지도 않았는데
빌드가되고, 해당 바이너리가 배포도 한방에 되었습니다.

헐.........
이거 호환이 되네?  Filter 도 등록이 되네? 어플리케이션도 실행이 되네?

개발이 쉽게다.!!!!!


일전  SmartPhone를 처음 개발 할때는 나름 적은 시간이 필요했는데....
요즘은 윈도우 모바일쪽을 일해보고 싶다는 마음이 굴뚝 같다는..........

Widnows Mobile Filter 개발자쯤?
네트워크 필터든 무엇이든..........
걍 취미로 개발 해야 하나...??????


그럼 고운하루.



[알고리즘]힙(heap)을 이용한 우선순위 큐

대딩때 가장 즐겁게 만들었던  우선순위 Heap입니다.^^
참 단촐 하면서도 가장 재미있게 한 레포트였습니다.

항상 n-1을 유지 하기 때문에 Static 한 Arrary를 Pointer 이용하여 각 노드들의
포인터만 저장 될 수 있도록 하고 Indexing을 통하여 우선순위 Heap을 핸들링 하는 것이
좋겠다 생각 한다.

Push와 Pop을 이용하여 새로운 Node를 삽입하게 되고
삽입 된 노드는 항상 가장 아래에 입력이 됩니다. 즉 N-1에 입력이 된다고 할 수 있다.

Pop이 이루어질 때는 우선 순위가 갖아 높은 최상의 Node가 Pop이 되고
Pop이 되면 자식 노드중 가장 큰 값을 다시 최상으로 올리는 재배열이
이루어져야 한다.

요것만 지켜지면 Max Heap이 됩니다.


 

아래 내용은 내용의 출처는 http://timenote.net/ 에  기록자 님의 작성한 원문이다.
특별히 저자분의 동의 없이 내용을 훔쳐 왔다는게 마음에 걸리고 동의를 받아야 하겠다.

힙(heap)이란 특수한 형태의 완전이진트리의 구조를 가진다.
힙은 각 노드의 키 값이(자식이 있다면) 그 자식의 키 값보다 작지 않은 완전 이진 트리이다.
힙의 구조를 살펴보면 아래와 같다.

사용자 삽입 이미지

완전 이진트리인 힙의 일반적인 형태


힙은 일반적으로 우선순위 큐(priority queue)를 구현할 때 자주 사용된다.
이전에 구현해 보았던 큐와는 달리 우선순위 큐에서는 우선순위가 가장 높은 원소를 먼저 삭제한다.
예를 들어 운영체제의 작업 스케줄러가 관리자에게 높은 우선순위를 부여하고 학생에게는 낮은 우선순위를 부여하는 우선순위 시스템을 사용한다고 가정하자.
이 경우 작업들을 유지하는 우선순위 큐를 최대 힙으로 구현할 수 있다.

힙은 우선순위 큐를 구현하는 한 방법일 뿐이다.
실제로 우선순위큐를 표현하기 위한 방법으로는 순서없는 배열, 순서없는 연결 리스트, 정렬된 배열, 정렬된 연결 리스트, 힙 등이 있다.
이 중 삽입과 삭제에 대한 복잡도가 둘다 log n의 복잡도를 가지는 것은 힙이다.
그렇기 때문에 우선순위큐를 표현하는 방법들중 힙을 선호하게 만든다.
그러면 힙의 삽입과 삭제 방법을 보도록하자.

아래 그림은 힙의 삽입 방법이다.

사용자 삽입 이미지

힙에서의 삽입 과정은 배열의 제일 뒤에 새로운 원소를 삽입하고 부모 노드의 키 값과 비교해서 부모 노드보다 작을 때까지 교체과정을 거친다.
즉, 삽입시에 최대한의 비교과정을 거치더라도 루트 노드까지만 비교하면 되므로 복잡도는 log n 을 따르게 된다.
다음은 힙에서 삭제가 일어나는 과정을 보도록 하겠다.

사용자 삽입 이미지

힙에서의 삭제 과정


힙에서의 삭제는 항상 루트의 값이 제거 되므로 루트의 값이 제거된 후에도 힙을 유지할 수 있도록 하기 위한 처리가 필요하다.
우선 완전 이진트리가 되어야 하므로 제일 뒤의 원소(여기서는 6)를 루트의 자리에 위치 시킨다.
그리고 힙의 특성상(여기서는 최대힙) 부모노드의 키값이 자식 노드의 키값보다 커야 하므로 자식 노드와 비교하면서 키값이 자식노드보다 클 때까지 반복해 나간다.

아래에는 힙을 구현하여 소스코드를 작성해 보았다.


그럼 고운하루... 되세요.
 



BLOG main image
취미생활
 Notice
 Category
분류 전체보기 (191)
매일매일갱생 (83)
서버개발 (1)
임베디드개발 (12)
Programming (80)
Personal Projects (6)
유용한 프로그램 (0)
 TAGS
영어 이메일 음식 English 벨소리 변경 서태지 VC++ ISDB-T debugging Dshow 출장 티스토리 초대장 1seg DVB Wince5.0 M480 개발자 DirectShow warning 군대 Brazil isdbt Algorithm Linux english email 퇴사 project 티스토리초대 알고리즘 Java spam mail Debug 미라지폰 C++ DVB-T C It Windows Mobile6.0 Error Case MP3
 Calendar
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
 Recent Entries
 Recent Comments
 Recent Trackbacks
 Archive
 Link Site
zextor
괴짜 프로그래머의 일상사~@@
Gag & Peace, and more..
Kazakhstan Almaty.......
Min-A
Sadgarret
Steve Yoon's log
가슴 뛰는 삶을 살아라
오스틴 파워
GUI sin
melanie parker_Lady
제레미의 TV 2.0 이야기..
 Visitor Statistics
Total :
Today :
Yesterday :
rss