cisst-saw
Loading...
Searching...
No Matches
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
4/*
5 Author(s): Anton Deguet
6 Created on: 2008-06-26
7
8 (C) Copyright 2008-2015 Johns Hopkins University (JHU), All Rights Reserved.
9
10 --- begin cisst license - do not edit ---
11
12 This software is provided "as is" under an open source license, with
13 no warranty. The complete license can be found in license.txt and
14 http://www.cisst.org/cisst/license.txt.
15
16 --- end cisst license ---
17*/
18
19#pragma once
20
21#ifndef _cmnAccessorMacros_h
22#define _cmnAccessorMacros_h
23
28
29
33#define CMN_DECLARE_MEMBER_AND_ACCESSORS_INTERNAL(memberType, memberName) \
34protected: \
35 memberType memberName##Member; \
36public: \
37 inline void Set##memberName(const memberType & newValue) { \
38 this->memberName##Member = newValue; \
39 } \
40 inline void Get##memberName(memberType & placeHolder) const { \
41 placeHolder = this->memberName##Member; \
42 } \
43 inline const memberType & memberName(void) const { \
44 return this->memberName##Member; \
45 } \
46 inline memberType & memberName(void) { \
47 return this->memberName##Member; \
48 } \
49protected:
50
68#ifndef SWIG
69 #define CMN_DECLARE_MEMBER_AND_ACCESSORS(memberType, memberName) \
70 CMN_DECLARE_MEMBER_AND_ACCESSORS_INTERNAL(memberType, memberName)
71#else
72 #define CMN_DECLARE_MEMBER_AND_ACCESSORS(memberType, memberName) \
73 CMN_DECLARE_MEMBER_AND_ACCESSORS_INTERNAL(memberType, memberName) \
74 %ignore Get##memberName(memberType &); \
75 public: \
76 %extend { \
77 const memberType & Get##memberName(void) const { \
78 return self->memberName(); \
79 } \
80 } \
81 protected:
82#endif
83
84#endif // _cmnAccessorMacros_h