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