MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
LookupValueFinfo.h
Go to the documentation of this file.
1 /**********************************************************************
2 ** This program is part of 'MOOSE', the
3 ** Messaging Object Oriented Simulation Environment.
4 ** Copyright (C) 2003-2009 Upinder S. Bhalla. and NCBS
5 ** It is made available under the terms of the
6 ** GNU Lesser General Public License version 2.1
7 ** See the file COPYING.LIB for the full notice.
8 **********************************************************************/
9 #ifndef _LOOKUP_VALUE_FINFO_H
10 #define _LOOKUP_VALUE_FINFO_H
11 
17 {
18  public:
20  {;}
21 
22  LookupValueFinfoBase( const string& name, const string& doc )
23  : Finfo( name, doc )
24  {;}
25 };
26 
34 template < class T, class L, class F > class LookupValueFinfo: public LookupValueFinfoBase
35 {
36  public:
38  delete set_;
39  delete get_;
40  }
41 
42  LookupValueFinfo( const string& name, const string& doc,
43  void ( T::*setFunc )( L, F ),
44  F ( T::*getFunc )( L ) const )
45  : LookupValueFinfoBase( name, doc )
46  {
47  string setname = "set" + name;
48  setname[3] = std::toupper( setname[3] );
49  set_ = new DestFinfo(
50  setname,
51  "Assigns field value.",
52  new OpFunc2< T, L, F >( setFunc ) );
53 
54  string getname = "get" + name;
55  getname[3] = std::toupper( getname[3] );
56  get_ = new DestFinfo(
57  getname,
58  "Requests field value. The requesting Element must "
59  "provide a handler for the returned value.",
60  new GetOpFunc1< T, L, F >( getFunc ) );
61  }
62 
63 
64  void registerFinfo( Cinfo* c ) {
65  c->registerFinfo( set_ );
66  c->registerFinfo( get_ );
67  }
68 
69  bool strSet( const Eref& tgt, const string& field,
70  const string& arg ) const {
71  string fieldPart = field.substr( 0, field.find( "[" ) );
72  string indexPart = field.substr( field.find( "[" ) + 1, field.find( "]" ) );
74  tgt.objId(), fieldPart, indexPart, arg );
75  }
76 
77  bool strGet( const Eref& tgt, const string& field,
78  string& returnValue ) const {
79  string fieldPart = field.substr( 0, field.find( "[" ) );
80  string indexPart = field.substr( field.find( "[" ) + 1, field.find( "]" ) );
82  fieldPart, indexPart, returnValue );
83  }
84 
85  string rttiType() const {
86  return Conv<L>::rttiType() + "," + Conv<F>::rttiType();
87  }
88 
89  private:
92 };
93 
94 template < class T, class L, class F > class ReadOnlyLookupValueFinfo: public LookupValueFinfoBase
95 {
96  public:
98  delete get_;
99  }
100 
101  ReadOnlyLookupValueFinfo( const string& name, const string& doc,
102  F ( T::*getFunc )( L ) const )
103  : LookupValueFinfoBase( name, doc )
104  {
105  string getname = "get" + name;
106  getname[3] = std::toupper( getname[3] );
107  get_ = new DestFinfo(
108  getname,
109  "Requests field value. The requesting Element must "
110  "provide a handler for the returned value.",
111  new GetOpFunc1< T, L, F >( getFunc ) );
112  }
113 
114 
115  void registerFinfo( Cinfo* c ) {
116  c->registerFinfo( get_ );
117  }
118 
119  bool strSet( const Eref& tgt, const string& field,
120  const string& arg ) const {
121  return 0;
122  }
123 
124  bool strGet( const Eref& tgt, const string& field,
125  string& returnValue ) const {
126  string fieldPart = field.substr( 0, field.find( "[" ) );
127  string indexPart = field.substr( field.find( "[" ) + 1, field.find( "]" ) );
129  fieldPart, indexPart, returnValue );
130  }
131 
132  string rttiType() const {
133  return Conv<L>::rttiType() + "," + Conv<F>::rttiType();
134  }
135 
136  private:
138 };
139 
140 #endif // _LOOKUP_VALUE_FINFO_H
bool strGet(const Eref &tgt, const string &field, string &returnValue) const
ReadOnlyLookupValueFinfo(const string &name, const string &doc, F(T::*getFunc)(L) const )
bool strGet(const Eref &tgt, const string &field, string &returnValue) const
void registerFinfo(Cinfo *c)
string rttiType() const
LookupValueFinfo(const string &name, const string &doc, void(T::*setFunc)(L, F), F(T::*getFunc)(L) const )
const string & name() const
Definition: Finfo.cpp:80
Definition: OpFunc.h:40
void registerFinfo(Finfo *f)
Definition: Cinfo.cpp:114
static bool innerStrSet(const ObjId &dest, const string &field, const string &indexStr, const string &val)
Definition: SetGet.h:514
ObjId objId() const
Definition: Eref.cpp:57
Definition: Eref.h:26
static bool innerStrGet(const ObjId &dest, const string &field, const string &indexStr, string &str)
Definition: SetGet.h:602
LookupValueFinfoBase(const string &name, const string &doc)
static string rttiType()
Definition: Conv.h:82
bool strSet(const Eref &tgt, const string &field, const string &arg) const
Definition: Cinfo.h:18
Definition: Finfo.h:12
bool strSet(const Eref &tgt, const string &field, const string &arg) const