Singleton 패턴
이번장에서는 프로그램 전체적으로 한개의 자원을 사용하는 경우 적용할 수 있는 디자인 패턴 Singleton 패턴에 대해 알아보겠습니다. 예를 들면 GPS, G sensor, 온도센서와 같은 모듈은 보통 한개의 제품에 한개씩 들어있습니다. 각각의 모듈을 초기화하고 사용하는 C 언어 Class를 만든다면 다음과 같이 Singleton을 활용할 수 있습니다. #define null (void *)0 typedef struct { init_function_t init; open_function_t open; connect_function_t connection; //... (필요시 추가) }device_t; device_t *get_gps_instance() { static device_t *instance =..