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