2010년 7월 26일 월요일

c++ Property

/// Getter & Setter define
#define GETSET(DATATYPE, GETTER, SETTER) __declspec(property(get=GETTER, put=SETTER)) DATATYPE
#define GET(DATATYPE, GETTER) __declspec(property(get=GETTER)) DATATYPE
#define SET(DATATYPE, SETTER) __declspec(property(put=SETTER)) DATATYPE

/// Variable Define
#define VARIABLE(DATATYPE, NAME); DATATYPE NAME;

/// Property Define
#define PROPERTY(DATATYPE, NAME, GET, SET) \
protected:                 \
   VARIABLE(DATATYPE, m_##NAME);    \
public:                  \
   GETSET(DATATYPE, GET, SET) NAME;

class CTEMP
{
public:

 int GetTest()
 {
  return this->m_TEST;
 }

 ///void SetTest(int nTest)
 int& SetTest(int value)
 {
  this->m_TEST = value;
  return this->m_TEST;
 }

 PROPERTY(int, TEST, GetTest, SetTest);
};

댓글 없음:

댓글 쓰기