cisst-saw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cmnAccessorMacros.h
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ex: set filetype=cpp softtabstop=4 shiftwidth=4 tabstop=4 cindent expandtab: */
3 
20 #pragma once
21 
22 #ifndef _cmnAccessorMacros_h
23 #define _cmnAccessorMacros_h
24 
34 #define CMN_DECLARE_MEMBER_AND_ACCESSORS_INTERNAL(memberType, memberName) \
35 protected: \
36  memberType memberName##Member; \
37 public: \
38  inline void Set##memberName(const memberType & newValue) { \
39  this->memberName##Member = newValue; \
40  } \
41  inline void Get##memberName(memberType & placeHolder) { \
42  placeHolder = this->memberName##Member; \
43  } \
44  inline const memberType & memberName(void) const { \
45  return this->memberName##Member; \
46  } \
47  inline memberType & memberName(void) { \
48  return this->memberName##Member; \
49  } \
50 protected:
51 
69 #ifndef SWIG
70  #define CMN_DECLARE_MEMBER_AND_ACCESSORS(memberType, memberName) \
71  CMN_DECLARE_MEMBER_AND_ACCESSORS_INTERNAL(memberType, memberName)
72 #else
73  #define CMN_DECLARE_MEMBER_AND_ACCESSORS(memberType, memberName) \
74  CMN_DECLARE_MEMBER_AND_ACCESSORS_INTERNAL(memberType, memberName) \
75  %ignore Get##memberName(memberType &); \
76  public: \
77  %extend { \
78  const memberType & Get##memberName(void) const { \
79  return self->memberName(); \
80  } \
81  } \
82  protected:
83 #endif
84 
85 #endif // _cmnAccessorMacros_h