2009년 4월 28일 화요일

좀 알고 쓰자(알파,베타 등등 )

(1) 알파(alpha, Α α)
(2) 베타(beta, Β β)
(3) 감마(gamma, Γ γ )
(4) 델타(delta, Δ δ)
(5) 입실론(epsilon, Ε ε)
(6) 제타(zeta, Ζ ζ )
(7) 이타(eta, Η η)
(8) 시타(theta, Θ θ)
(9) 이오타(iota, Ι ι)
(10) 카파(kappa, Κ κ)
(11) 람다(lambda, Λ λ)
(12) 뮤(mu, Μ μ)
(13) 뉴(nu, Ν ν)
(14) 크사이(xi, Ξ ξ)
(15) 오미크론(Omicron, Ο ο)
(16) 파이(pi, Π π)
(17) 로(rho, Ρ ρ)
(18) 시그마(sigma, Σ σ)
(19) 타우(tau, Τ τ)
(20) 윕실론(upsilon, Υ υ)
(21) 파이(phi, Φ φ)
(22) 카이(khi, Χ χ)
(23) 프시(psi, Ψ ψ)
(24) 오메가(omega, Ω ω)

2009년 4월 16일 목요일

exception

More effective c++
Exception

void processAdoptions ( istream & dataSource )
{
    while (dataSource ) {
        ALA *pa = readALA ( dataSource ) ;
        pa -> processAdoptions () ;
        delete pa ;
    }
}

# way to handle processAdoptions ()  function exception

1. try - catch

void processAdoptions ( istream & dataSource )
{
    while ( dataSource ) {
        ALA * pa = readALA (dataSource ) ;
       
        try {
            pa->processAdoptions () ;
        }
        catch(...){
            delete pa;

            throw ;
        }

        delete pa ;
    }

}

2. using auto_ptr ( one of smart pointer )

void processAdoptions ( istream & dataSource )
{
    while (dataSource ) {
        auto_ptr <ALA> pa ( readALA ( dataSource ) ) ;
        pa -> processAdoptions () ;
    }
}

# resource leakage in contrutor

class BookEntry {
    public :

    BookEntry ( const string & name , const string & address = "" ,
    const string & imageFileName = "", const string * audioClipFileName = "") ;
    ~BookEntry() ;

    void addPhoneNumber( const PhoneNumber & number ) ;

    private :
        string theName ;
        string theAddress ;
        list<PhoneNumber> thePhone ;
        Image * theImage ;
        AudioClip * theAudioClip ;
} ;

 - construction definition

BookEntry::BookEntry ( const string & name , const string & address = "" ,
    const string & imageFileName = "", const string * audioClipFileName = "") :
    theName ( name ) , theAddress(address) , theImage ( 0) , theAudioClip (0)
{
        ...
        theImage = new Image ( imageFileName ) ;

        theAudioClip= new AuioClip ( audioClipFileName ) ;

        ...
}

# fully constructed -> deconstructor

1. try {
      ...
      theImage = new Image (imageFileName ) ;

      ..
      theAudioClip= new AuioClip ( audioClipFileName ) ;
    }
    catch ( ...)
    {
        delete theImage ;
        delete theAudioClip;

    }

# if the pointer is constant ?

Image * const theImage ;
AudioCLip * cosnt theAudioClip

BookEntry::BookEntry ( const string & name , const string & address = "" ,
    const string & imageFileName = "", const string * audioClipFileName = "") :
    theName ( name ) , theAddress(address) , theImage ( initImage(imageFileName ) ) , theAudioClip (initAudioClip(audioclipFileName))
{ }

#for exception handling in destructdor
session::~session ()
{
   try{ logDeestruction(this ) ;
   }
   catch(...) {}
}



2009년 4월 12일 일요일

리눅스 thread

2009년 4월 8일 수요일

함수 포인터란?

2009년 4월 7일 화요일

SetTimer(), KillTimer()

1. SetTimer 함수는 일정시간 마다 WM_TIMER 메시지를 발생시킨다.
2. WM_TIMER 메시지가 발생하면 OnTimer 함수를 호출한다.


SetTimer(0,1000,NULL); //SetTimer함수는 아래와 같다.

//SetTimer(타이머번호, 설정된 시간간격, 타이머 메시지가 발생되었을때 실행되는 함수

// 설정된 시간이 '1000' 이면 1초 간격을 뜻한다.

SetTimer(1,800,NULL);


void Test::OnTimer(UINT nIDEvent)
{
 if ( nIDEvent == 0 ) {
  // ID가 0인 타이머 }
 if ( nIDEvent ==1 ) {
  // ID가 1인 타이머 }
}

이런식으로 하면 여러개의 타이머를 서로 다른 시간에 작동 시킬수 있다.


한가지더...
보통 SetTimer 함수는 OnInitialUpdate 함수에 설정한다.
OnInitialUpdate 함수는 뷰 윈도우가 최초로 화면에 나타나는 순간에
호출되는 함수이다


그럼 동작중인 타이머를 끌려면 다음과 같이 하면 된다.


윈도우가 없어지는 순간 즉 WM_DESTROY 메시지가 발생하면

KillTimer(0); // 괄호안의 숫자는 타이머 번지를 나타낸다.

KillTimer(1);



2009년 4월 6일 월요일

library만들기

Volatile variable