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