WxExtLib - accessor_macros.h
00001: // -*- c++ -*-
00002:
00003: //-------------------------------------------------------------------------
00004: // Author: Daniel Käps, created 2006.
00005: // This file is public domain.
00006: //-------------------------------------------------------------------------
00007:
00008: //-------------------------------------------------------------------------
00009: // NOTES
00010: // - some macros currently require use of stx/sontaia StxPrimitives.h and/or
00011: // StxBasicType.h (specifically M_DeclareBitProperty() etc.)
00012: //-------------------------------------------------------------------------
00013:
00014: //-------------------------------------------------------------------------
00015: //
00016: // NOTE ...WithoutSet() macro variants may be useful if :
00017: // - ParameterType doesn't support assignment
00018: // - if specialized set[ParameterType]() function is required which does
00019: // more than just assigning the value (e.g. updating other internal
00020: // variables)
00021:
00022: #define M_DeclarePtrPropertyWithoutSet(ParameterType,ParameterName) \
00023: public: \
00024: ParameterType * get##ParameterName () const \
00025: { \
00026: return m_##ParameterName; \
00027: } \
00028: private: \
00029: ParameterType * m_##ParameterName \
00030:
00031: #define M_DeclarePtrProperty(ParameterType,ParameterName) \
00032: public: \
00033: void set##ParameterName (ParameterType * ParameterName) \
00034: { \
00035: m_##ParameterName = ParameterName; \
00036: } \
00037: M_DeclarePtrPropertyWithoutSet(ParameterType,ParameterName) \
00038:
00039: //-------------------------------------------------------------------------
00040:
00041: #define M_DeclarePropertyWithoutSet(ParameterType,ParameterName) \
00042: public: \
00043: const ParameterType & get##ParameterName () const \
00044: { \
00045: return m_##ParameterName; \
00046: } \
00047: ParameterType & access##ParameterName () \
00048: { \
00049: return m_##ParameterName; \
00050: } \
00051: bool getIs##ParameterName##Initialized () const \
00052: { \
00053: return m_Is##ParameterName##Initialized; \
00054: } \
00055: void set##ParameterName##InitializedState (bool IsInitialized = true) \
00056: { \
00057: m_Is##ParameterName##Initialized = IsInitialized; \
00058: } \
00059: private: \
00060: ParameterType m_##ParameterName; \
00061: bool m_Is##ParameterName##Initialized \
00062:
00063: //-------------------------------------------------------------------------
00064:
00065: #define M_DeclareProperty(ParameterType,ParameterName) \
00066: public: \
00067: void set##ParameterName (const ParameterType & ParameterName) \
00068: { \
00069: m_##ParameterName = ParameterName; \
00070: m_Is##ParameterName##Initialized = true; \
00071: } \
00072: M_DeclarePropertyWithoutSet(ParameterType,ParameterName) \
00073:
00074: //-------------------------------------------------------------------------
00075:
00076: #define M_DeclarePropertyWithoutSetWithoutInitState(ParameterType,ParameterName) \
00077: public: \
00078: const ParameterType & get##ParameterName () const \
00079: { \
00080: return m_##ParameterName; \
00081: } \
00082: ParameterType & access##ParameterName () \
00083: { \
00084: return m_##ParameterName; \
00085: } \
00086: private: \
00087: ParameterType m_##ParameterName \
00088:
00089: //-------------------------------------------------------------------------
00090:
00091: #define M_DeclarePropertyWithoutInitState(ParameterType,ParameterName) \
00092: public: \
00093: void set##ParameterName (const ParameterType & ParameterName) \
00094: { \
00095: m_##ParameterName = ParameterName; \
00096: } \
00097: M_DeclarePropertyWithoutSetWithoutInitState(ParameterType,ParameterName) \
00098:
00099: //-------------------------------------------------------------------------
00100:
00101: #define M_DeclareBitProperty(ModeBits,ParameterName) \
00102: public: \
00103: void set##ParameterName (bool IsEnable) \
00104: { \
00105: ::stxEnableBit (m_ModeBits, ParameterName, IsEnable); \
00106: } \
00107: bool get##ParameterName () \
00108: { \
00109: return ::stxGetBit (ModeBits, ParameterName); \
00110: } \
00111:
00112: #define M_DeclareModeBits(EMode,ModeBits) \
00113: public: \
00114: bool get##ModeBits (EMode Mode) { return ::stxGetBit (ModeBits, Mode); } \
00115: void enable##ModeBits (EMode Mode, bool IsEnable) { ::stxEnableBit (ModeBits, Mode, IsEnable); } \
00116: private: \
00117: EMode m_ModeBits \
00118:
00119: //-------------------------------------------------------------------------
00120: