class object
{
private:
 typedef unsigned int uint_t;
 typedef void (object::*object_proc)(uint_t param);

 std::map<uint_t, object::object_proc> _lookup_of_object_proc;

public:
 uint_t _value;

public:
 void initialize (void)
 {
  _lookup_of_object_proc[0] = &object::test_1;
  _lookup_of_object_proc[1] = &object::test_2;
 }

 void test_1 (uint_t param)
 {
  printf ("test_1 = %d %d \r\n",_value, param);
 }

 void test_2 (uint_t param)
 {
  printf ("test_2 = %d %d \r\n", _value, param);
 }

 void run (uint_t id, uint_t value)
 {
  object_proc proc = _lookup_of_object_proc[id];

  if (proc)
  {
   (this->*proc) (value);
  }
 }
};

int _tmain(int argc, _TCHAR* argv[])
{
 HRESULT hRes = ::CoInitialize(NULL);

 assert(SUCCEEDED(hRes));


 object a,b;

 a.initialize();
 b.initialize();

 a._value = 10;
 b._value = 20;

 a.run (0, 1);
 a.run (1, 2);

 b.run (0, 1);
 b.run (1, 2);

 ::CoUninitialize();

 return 0;
}



---------------------------------------------------------
test_1 = 10 1
test_2 = 10 2
test_1 = 20 1
test_2 = 20 2
계속하려면 아무 키나 누르십시오 . . .

Posted by 셈말짓기 :


std::for_each(m_Module.begin(), m_Module.end(), DeleteWindowObject<CVMEModuleWidget*>); 

template <typename TYPE>
static void DeleteWindowObject (TYPE p)
{
 p->DestroyWindow();
 delete p;
}

template <typename TYPE>
static void DeletePointer (TYPE p)
{
 delete p;
}

template <typename TYPE>
static void DeleteArrayPointer (TYPE p)
{
 delete []p;

 template <typename TYPE>
 static void delete_pointer_of_std_pair_second (TYPE p)
 {
  delete p.second;
 }

Posted by 셈말짓기 :

# SVN 사용시 아래 파일은 무시하도록 설정한다.

1. 위치
[TortoiseSVN 설정 / 일반 / Subversion / 제외/무시 패턴(&P)]

2. 기본값
*.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo *.rej *~ #*# .#* .*.swp .DS_Store

3. 추가 내용
Thumbs.db *.map *.exe *.res mt.dep BuildLog.htm *.ilk *.exe.embed.manifest *.exe.intermediate.manifest *.obj *.pch *.pdb *.idb *.user *.aps *.ncb *.suo

4. 추가 후 내용
Thumbs.db *.map *.exe *.res mt.dep BuildLog.htm *.ilk *.exe.embed.manifest *.exe.intermediate.manifest *.obj *.pch *.pdb *.idb *.user *.aps *.ncb *.suo *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo *.rej *~ #*# .#* .*.swp .DS_Store


# SVN 과 연결을 해제 하면서 .svn하위 파일을 삭제 하는 쉘 스크립트
[Delete SVN Folders.reg]
----------------------------------------------------------------------------------------------------
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN]
@="Delete SVN Folders"

[HKEY_LOCAL_MACHINE\SOFTWARE\Classes\Folder\shell\DeleteSVN\command]
@="cmd.exe /c \"TITLE Removing SVN Folders in %1 && COLOR 9A && FOR /r \"%1\" %%f IN (.svn) DO RD /s /q \"%%f\" \""
----------------------------------------------------------------------------------------------------

Posted by 셈말짓기 :


static const WORD MAX_CONSOLE_LINES = 500;

#include <fcntl.h>
#include <io.h>
#include <iostream>
#include <fstream>

void RedirectIOToConsole()
{
 int hConHandle;
 long lStdHandle;

 CONSOLE_SCREEN_BUFFER_INFO coninfo;

 FILE *fp;

 // allocate a console for this app

 AllocConsole();

 // set the screen buffer to be big enough to let us scroll text
 GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &coninfo);

 coninfo.dwSize.Y = MAX_CONSOLE_LINES;
 SetConsoleScreenBufferSize(GetStdHandle(STD_OUTPUT_HANDLE), coninfo.dwSize);

 // redirect unbuffered STDOUT to the console
 lStdHandle = (long)GetStdHandle(STD_OUTPUT_HANDLE);
 hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
 fp = _fdopen( hConHandle, "w" );
 *stdout = *fp;
 setvbuf( stdout, NULL, _IONBF, 0 );

 // redirect unbuffered STDIN to the console
 lStdHandle = (long)GetStdHandle(STD_INPUT_HANDLE);
 hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
 fp = _fdopen( hConHandle, "r" );
 *stdin = *fp;
 setvbuf( stdin, NULL, _IONBF, 0 );

 // redirect unbuffered STDERR to the console
 lStdHandle = (long)GetStdHandle(STD_ERROR_HANDLE);
 hConHandle = _open_osfhandle(lStdHandle, _O_TEXT);
 fp = _fdopen( hConHandle, "w" );
 *stderr = *fp;
 setvbuf( stderr, NULL, _IONBF, 0 );

 // make cout, wcout, cin, wcin, wcerr, cerr, wclog and clog
 // point to console as well
 std::ios::sync_with_stdio();
}

Posted by 셈말짓기 :

static_cast
It is able to do the reverse of what an implicit conversion can do. Meaning: narrow (long -> int), widen (int -> long), base-to-derived, void*-to-T* for example. You can't use it for the stuff that an reversed implicit conversion cannot do. (I.e you cannot cast an int* into int).


dynamic_cast
It is used to cast a base pointer into a derived pointer. If the base pointer doesn't point to an object of the type of the derived, it returns 0.
It is used to cast a base reference into a derived reference. If the reference isn't pointing to an object of the derived, it throws std::bad_cast.
It can be considered the checked cast equivalent to static_cast, in that it checks whether the object pointed to really is of the derived type.


reinterpret_cast

It is used to cast a pointer type to a wide enough integral type and back to the original pointer type.
It is used to cast between pointer types of incompatible types (int* to double* for example). The result of that mapping is unspecified, but it's possible to do so.


const_cast

It is used to cast away const or volatile. It is used in the rare cases when you have a originally non-const object, which is pointed to by a pointer-to-const or referenced to by a reference-to-const. Casting away constness is considered evil and should not be done if it can be avoided.

Posted by 셈말짓기 :