00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef _ELEMENT_VALUE_FINFO_H
00010 #define _ELEMENT_VALUE_FINFO_H
00011
00016 template < class T, class F > class ElementValueFinfo: public ValueFinfoBase
00017 {
00018 public:
00019 ~ElementValueFinfo() {
00020 delete set_;
00021 delete get_;
00022 }
00023
00024 ElementValueFinfo( const string& name, const string& doc,
00025 void ( T::*setFunc )( const Eref&, F ),
00026 F ( T::*getFunc )( const Eref& ) const )
00027 : ValueFinfoBase( name, doc )
00028 {
00029 string setname = "set" + name;
00030 setname[3] = toupper( setname[3] );
00031 set_ = new DestFinfo(
00032 setname,
00033 "Assigns field value.",
00034 new EpFunc1< T, F >( setFunc ) );
00035
00036 string getname = "get" + name;
00037 getname[3] = toupper( getname[3] );
00038 get_ = new DestFinfo(
00039 getname,
00040 "Requests field value. The requesting Element must "
00041 "provide a handler for the returned value.",
00042 new GetEpFunc< T, F >( getFunc ) );
00043 }
00044
00045
00046 void registerFinfo( Cinfo* c ) {
00047 c->registerFinfo( set_ );
00048
00049 c->registerFinfo( get_ );
00050 }
00051
00052 bool strSet( const Eref& tgt, const string& field,
00053 const string& arg ) const {
00054 return Field< F >::innerStrSet( tgt.objId(), field, arg );
00055 }
00056
00057 bool strGet( const Eref& tgt, const string& field,
00058 string& returnValue ) const {
00059 return Field< F >::innerStrGet(
00060 tgt.objId(), field, returnValue );
00061 }
00062
00063 string rttiType() const {
00064 return Conv<F>::rttiType();
00065 }
00066
00067 private:
00068 };
00069
00070 template < class T, class F > class ReadOnlyElementValueFinfo: public ValueFinfoBase
00071 {
00072 public:
00073 ~ReadOnlyElementValueFinfo() {
00074 delete get_;
00075 }
00076
00077 ReadOnlyElementValueFinfo( const string& name, const string& doc,
00078 F ( T::*getFunc )( const Eref& e ) const )
00079 : ValueFinfoBase( name, doc )
00080 {
00081 string getname = "get" + name;
00082 getname[3] = toupper( getname[3] );
00083 get_ = new DestFinfo(
00084 getname,
00085 "Requests field value. The requesting Element must "
00086 "provide a handler for the returned value.",
00087 new GetEpFunc< T, F >( getFunc ) );
00088 }
00089
00090
00091 void registerFinfo( Cinfo* c ) {
00092 c->registerFinfo( get_ );
00093 }
00094
00095 bool strSet( const Eref& tgt, const string& field,
00096 const string& arg ) const {
00097 return 0;
00098 }
00099
00100 bool strGet( const Eref& tgt, const string& field,
00101 string& returnValue ) const {
00102 return Field< F >::innerStrGet(
00103 tgt.objId(), field, returnValue );
00104 }
00105
00106 string rttiType() const {
00107 return Conv<F>::rttiType();
00108 }
00109
00110 private:
00111 };
00112
00113 #endif // _ELEMENT_VALUE_FINFO_H