MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
LookupElementValueFinfo.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_ELEMENT_VALUE_FINFO_H
10 #define _LOOKUP_ELEMENT_VALUE_FINFO_H
11 
19 template < class T, class L, class F > class LookupElementValueFinfo: public LookupValueFinfoBase
20 {
21  public:
23  delete set_;
24  delete get_;
25  }
26 
27  LookupElementValueFinfo( const string& name, const string& doc,
28  void ( T::*setFunc )( const Eref&, L, F ),
29  F ( T::*getFunc )( const Eref&, L ) const )
30  : LookupValueFinfoBase( name, doc )
31  {
32  string setname = "set" + name;
33  setname[3] = std::toupper( setname[3] );
34  set_ = new DestFinfo(
35  setname,
36  "Assigns field value.",
37  new EpFunc2< T, L, F >( setFunc ) );
38 
39  string getname = "get" + name;
40  getname[3] = std::toupper( getname[3] );
41  get_ = new DestFinfo(
42  getname,
43  "Requests field value. The requesting Element must "
44  "provide a handler for the returned value.",
45  new GetEpFunc1< T, L, F >( getFunc ) );
46  }
47 
48 
49  void registerFinfo( Cinfo* c ) {
50  c->registerFinfo( set_ );
51  c->registerFinfo( get_ );
52  }
53 
54  bool strSet( const Eref& tgt, const string& field,
55  const string& arg ) const {
56  string fieldPart = field.substr( 0, field.find( "[" ) );
57  string indexPart = field.substr( field.find( "[" ) + 1, field.find( "]" ) );
59  tgt.objId(), fieldPart, indexPart, arg );
60  }
61 
62  bool strGet( const Eref& tgt, const string& field,
63  string& returnValue ) const {
64  string fieldPart = field.substr( 0, field.find( "[" ) );
65  string indexPart = field.substr( field.find( "[" ) + 1, field.find( "]" ) );
67  tgt.objId(), fieldPart, indexPart, returnValue );
68  }
69 
70  string rttiType() const {
71  return Conv<L>::rttiType() + "," + Conv<F>::rttiType();
72  }
73 
74  private:
77 };
78 
79 template < class T, class L, class F >
81 {
82  public:
84  delete get_;
85  }
86 
88  const string& name, const string& doc,
89  F ( T::*getFunc )( const Eref& e, L ) const )
90  : LookupValueFinfoBase( name, doc )
91  {
92  string getname = "get" + name;
93  getname[3] = std::toupper( getname[3] );
94  get_ = new DestFinfo(
95  getname,
96  "Requests field value. The requesting Element must "
97  "provide a handler for the returned value.",
98  new GetEpFunc1< T, L, F >( getFunc ) );
99  }
100 
101 
102  void registerFinfo( Cinfo* c ) {
103  c->registerFinfo( get_ );
104  }
105 
106  bool strSet( const Eref& tgt, const string& field,
107  const string& arg ) const {
108  return 0;
109  }
110 
111  bool strGet( const Eref& tgt, const string& field,
112  string& returnValue ) const {
113  string fieldPart = field.substr( 0, field.find( "[" ) );
114  string indexPart = field.substr( field.find( "[" ) + 1, field.find( "]" ) );
116  tgt.objId(), fieldPart, indexPart, returnValue );
117  }
118 
119  string rttiType() const {
120  return Conv<L>::rttiType() + "," + Conv<F>::rttiType();
121  }
122 
123  private:
125 };
126 
127 #endif // _LOOKUP_ELEMENT_VALUE_FINFO_H
const string & name() const
Definition: Finfo.cpp:80
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
bool strSet(const Eref &tgt, const string &field, const string &arg) const
ReadOnlyLookupElementValueFinfo(const string &name, const string &doc, F(T::*getFunc)(const Eref &e, L) const )
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
bool strGet(const Eref &tgt, const string &field, string &returnValue) const
bool strGet(const Eref &tgt, const string &field, string &returnValue) const
bool strSet(const Eref &tgt, const string &field, const string &arg) const
static string rttiType()
Definition: Conv.h:82
LookupElementValueFinfo(const string &name, const string &doc, void(T::*setFunc)(const Eref &, L, F), F(T::*getFunc)(const Eref &, L) const )
Definition: Cinfo.h:18
Definition: EpFunc.h:79