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