MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
ValueFinfo.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 _VALUE_FINFO_H
10 #define _VALUE_FINFO_H
11 
16 class ValueFinfoBase: public Finfo
17 {
18  public:
20  {;}
21 
22  ValueFinfoBase( const string& name, const string& doc );
23 
24  DestFinfo* getFinfo() const;
25 
27  // Override the default virtual function for the set/get destfinfos
29 
30  vector< string > innerDest() const;
31  protected:
34 };
35 
36 template < class T, class F > class ValueFinfo: public ValueFinfoBase
37 {
38  public:
40  delete set_;
41  delete get_;
42  }
43 
44  ValueFinfo( const string& name, const string& doc,
45  void ( T::*setFunc )( F ),
46  F ( T::*getFunc )() const )
47  : ValueFinfoBase( name, doc )
48  {
49  string setname = "set" + name;
50  setname[3] = std::toupper( setname[3] );
51  set_ = new DestFinfo(
52  setname,
53  "Assigns field value.",
54  new OpFunc1< T, F >( setFunc ) );
55 
56  string getname = "get" + name;
57  getname[3] = std::toupper( getname[3] );
58  get_ = new DestFinfo(
59  getname,
60  "Requests field value. The requesting Element must "
61  "provide a handler for the returned value.",
62  new GetOpFunc< T, F >( getFunc ) );
63  }
64 
65 
66  void registerFinfo( Cinfo* c ) {
67  c->registerFinfo( set_ );
68  c->registerFinfo( get_ );
69  }
70 
71  bool strSet( const Eref& tgt, const string& field,
72  const string& arg ) const {
73  return Field< F >::innerStrSet( tgt.objId(), field, arg );
74  }
75 
76  bool strGet( const Eref& tgt, const string& field,
77  string& returnValue ) const {
78  return Field< F >::innerStrGet( tgt.objId(), field, returnValue );
79  }
80 
81  string rttiType() const {
82  return Conv<F>::rttiType();
83  }
84  private:
85 };
86 
87 template < class T, class F > class ReadOnlyValueFinfo: public ValueFinfoBase
88 {
89  public:
91  delete get_;
92  }
93 
94  ReadOnlyValueFinfo( const string& name, const string& doc,
95  F ( T::*getFunc )() const )
96  : ValueFinfoBase( name, doc )
97  {
98  string getname = "get" + name;
99  getname[3] = std::toupper( getname[3] );
100  get_ = new DestFinfo(
101  getname,
102  "Requests field value. The requesting Element must "
103  "provide a handler for the returned value.",
104  new GetOpFunc< T, F >( getFunc ) );
105  }
106 
107 
108  void registerFinfo( Cinfo* c ) {
109  c->registerFinfo( get_ );
110  }
111 
112  bool strSet( const Eref& tgt, const string& field,
113  const string& arg ) const {
114  return 0;
115  }
116 
117  bool strGet( const Eref& tgt, const string& field,
118  string& returnValue ) const {
120  tgt.objId(), field, returnValue );
121  }
122 
123  string rttiType() const {
124  return Conv<F>::rttiType();
125  }
126 
127  private:
128 };
129 
130 #endif // _VALUE_FINFO_H
bool strGet(const Eref &tgt, const string &field, string &returnValue) const
Definition: ValueFinfo.h:76
DestFinfo * getFinfo() const
Definition: ValueFinfo.cpp:18
bool strGet(const Eref &tgt, const string &field, string &returnValue) const
Definition: ValueFinfo.h:117
DestFinfo * get_
Definition: ValueFinfo.h:33
ValueFinfoBase(const string &name, const string &doc)
Definition: ValueFinfo.cpp:12
const string & name() const
Definition: Finfo.cpp:80
ReadOnlyValueFinfo(const string &name, const string &doc, F(T::*getFunc)() const )
Definition: ValueFinfo.h:94
void registerFinfo(Finfo *f)
Definition: Cinfo.cpp:114
static bool innerStrSet(const ObjId &dest, const string &field, const string &arg)
Definition: SetGet.h:271
static bool innerStrGet(const ObjId &dest, const string &field, string &str)
Definition: SetGet.h:345
string rttiType() const
Definition: ValueFinfo.h:123
DestFinfo * set_
Definition: ValueFinfo.h:32
ObjId objId() const
Definition: Eref.cpp:57
Definition: OpFunc.h:27
Definition: Eref.h:26
void registerFinfo(Cinfo *c)
Definition: ValueFinfo.h:66
bool strSet(const Eref &tgt, const string &field, const string &arg) const
Definition: ValueFinfo.h:112
vector< string > innerDest() const
Definition: ValueFinfo.cpp:22
bool strSet(const Eref &tgt, const string &field, const string &arg) const
Definition: ValueFinfo.h:71
static string rttiType()
Definition: Conv.h:82
string rttiType() const
Definition: ValueFinfo.h:81
ValueFinfo(const string &name, const string &doc, void(T::*setFunc)(F), F(T::*getFunc)() const )
Definition: ValueFinfo.h:44
Definition: Cinfo.h:18
void registerFinfo(Cinfo *c)
Definition: ValueFinfo.h:108
Definition: Finfo.h:12