|
Rcpp Version 0.9.10
|
00001 // -*- mode: C++; c-indent-level: 4; c-basic-offset: 4; tab-width: 8 -*- 00002 // 00003 // Module_Add_Property.h: Rcpp R/C++ interface class library -- Rcpp modules 00004 // 00005 // Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois 00006 // 00007 // This file is part of Rcpp. 00008 // 00009 // Rcpp is free software: you can redistribute it and/or modify it 00010 // under the terms of the GNU General Public License as published by 00011 // the Free Software Foundation, either version 2 of the License, or 00012 // (at your option) any later version. 00013 // 00014 // Rcpp is distributed in the hope that it will be useful, but 00015 // WITHOUT ANY WARRANTY; without even the implied warranty of 00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 // GNU General Public License for more details. 00018 // 00019 // You should have received a copy of the GNU General Public License 00020 // along with Rcpp. If not, see <http://www.gnu.org/licenses/>. 00021 00022 #ifndef Rcpp_Module_Add_Property_h 00023 #define Rcpp_Module_Add_Property_h 00024 00025 template <typename PROP> 00026 self& property( const char* name_, PROP (Class::*GetMethod)(void), const char* docstring = 0){ 00027 AddProperty( name_, new CppProperty_GetMethod<Class,PROP>(GetMethod, docstring) ) ; 00028 return *this ; 00029 } 00030 00031 template <typename PROP> 00032 self& property( const char* name_, PROP (Class::*GetMethod)(void) const, const char* docstring = 0){ 00033 AddProperty( name_, new CppProperty_GetConstMethod<Class,PROP>(GetMethod, docstring) ) ; 00034 return *this ; 00035 } 00036 00037 template <typename PROP> 00038 self& property( const char* name_, PROP (*GetMethod)(Class*), const char* docstring ){ 00039 AddProperty( name_, new CppProperty_GetPointerMethod<Class,PROP>(GetMethod,docstring) ) ; 00040 return *this ; 00041 } 00042 00043 00044 template <typename PROP> 00045 self& property( const char* name_, PROP (Class::*GetMethod)(void), void (Class::*SetMethod)(PROP), const char* docstring = 0){ 00046 AddProperty( 00047 name_, 00048 new CppProperty_GetMethod_SetMethod<Class,PROP>(GetMethod, SetMethod, docstring) 00049 ) ; 00050 return *this ; 00051 } 00052 template <typename PROP> 00053 self& property( const char* name_, PROP (Class::*GetMethod)(void) const, void (Class::*SetMethod)(PROP), const char* docstring = 0){ 00054 AddProperty( 00055 name_, 00056 new CppProperty_GetConstMethod_SetMethod<Class,PROP>(GetMethod, SetMethod, docstring) 00057 ) ; 00058 return *this ; 00059 } 00060 00061 00062 template <typename PROP> 00063 self& property( const char* name_, PROP (Class::*GetMethod)(void), void (*SetMethod)(Class*,PROP), const char* docstring = 0 ){ 00064 AddProperty( 00065 name_, 00066 new CppProperty_GetMethod_SetPointer<Class,PROP>(GetMethod, SetMethod, docstring ) 00067 ) ; 00068 return *this ; 00069 } 00070 template <typename PROP> 00071 self& property( const char* name_, PROP (Class::*GetMethod)(void) const , void (*SetMethod)(Class*,PROP), const char* docstring = 0 ){ 00072 AddProperty( 00073 name_, 00074 new CppProperty_GetConstMethod_SetPointer<Class,PROP>(GetMethod, SetMethod, docstring) 00075 ) ; 00076 return *this ; 00077 } 00078 00079 00080 template <typename PROP> 00081 self& property( const char* name_, PROP (*GetMethod)(Class*), void (Class::*SetMethod)(PROP), const char* docstring = 0 ){ 00082 AddProperty( 00083 name_, 00084 new CppProperty_GetPointer_SetMethod<Class,PROP>(GetMethod, SetMethod, docstring) 00085 ) ; 00086 } 00087 00088 template <typename PROP> 00089 self& property( const char* name_, PROP (*GetMethod)(Class*), void (*SetMethod)(Class*,PROP), const char* docstring = 0 ){ 00090 AddProperty( 00091 name_, 00092 new CppProperty_GetPointer_SetPointer<Class,PROP>(GetMethod, SetMethod, docstring) 00093 ) ; 00094 return *this ; 00095 } 00096 00097 00098 #endif