MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
LookupField< L, A > Class Template Reference

#include <SetGet.h>

+ Inheritance diagram for LookupField< L, A >:
+ Collaboration diagram for LookupField< L, A >:

Public Member Functions

 LookupField (const ObjId &dest)
 
- Public Member Functions inherited from SetGet2< L, A >
 SetGet2 ()
 
- Public Member Functions inherited from SetGet
virtual bool checkOpClass (const OpFunc *op) const =0
 
 SetGet ()
 
virtual ~SetGet ()
 

Static Public Member Functions

static A get (const ObjId &dest, const string &field, L index)
 
static void getVec (Id dest, const string &field, vector< L > &index, vector< A > &vec)
 
static bool innerStrGet (const ObjId &dest, const string &field, const string &indexStr, string &str)
 
static bool innerStrSet (const ObjId &dest, const string &field, const string &indexStr, const string &val)
 
static bool set (const ObjId &dest, const string &field, L index, A arg)
 
static bool setRepeat (Id destId, const string &field, const vector< L > &index, A arg)
 
static bool setVec (Id destId, const string &field, const vector< L > &index, const vector< A > &arg)
 
static bool setVec (ObjId dest, const string &field, const vector< L > &index, const vector< A > &arg)
 
- Static Public Member Functions inherited from SetGet2< L, A >
static bool innerStrSet (const ObjId &dest, const string &field, const string &val)
 
static bool set (const ObjId &dest, const string &field, Larg1, Aarg2)
 
static bool setVec (Id destId, const string &field, const vector< L > &arg1, const vector< A > &arg2)
 
- Static Public Member Functions inherited from SetGet
static const OpFunccheckSet (const string &field, ObjId &tgt, FuncId &fid)
 
static const vector< double * > * dispatchGet (const ObjId &tgt, FuncId tgtFid, const double *arg, unsigned int size)
 Sends out request for data, and awaits its return. More...
 
static bool strGet (const ObjId &tgt, const string &field, string &ret)
 
static bool strSet (const ObjId &dest, const string &field, const string &val)
 

Detailed Description

template<class L, class A>
class LookupField< L, A >

LookupField handles fields that have an index arguments. Examples include arrays and maps. The first argument in the 'Set' is the index, the second the value. The first and only argument in the 'get' is the index. Here A is the type of the value, and L the lookup index.

Definition at line 457 of file SetGet.h.

Constructor & Destructor Documentation

template<class L, class A>
LookupField< L, A >::LookupField ( const ObjId dest)
inline

Definition at line 460 of file SetGet.h.

461  : SetGet2< L, A >( dest )
462  {;}

Member Function Documentation

template<class L, class A>
static A LookupField< L, A >::get ( const ObjId dest,
const string &  field,
index 
)
inlinestatic

Gets a value on a specific object, looking it up using the provided index.

Definition at line 532 of file SetGet.h.

References SetGet::checkSet(), ObjId::eref(), ObjId::isDataHere(), and LookupGetOpFuncBase< L, A >::returnOp().

Referenced by get_simple_lookupfield(), Neutral::getDt(), lookupVolumeFromMesh(), SteadyState::setStoich(), testGetMsg(), testLookupSetGet(), and testTable().

533  {
534  ObjId tgt( dest );
535  FuncId fid;
536  string fullFieldName = "get" + field;
537  fullFieldName[3] = std::toupper( fullFieldName[3] );
538  const OpFunc* func = SetGet::checkSet( fullFieldName, tgt, fid);
539  const LookupGetOpFuncBase< L, A >* gof =
540  dynamic_cast< const LookupGetOpFuncBase< L, A >* >( func );
541  if ( gof ) {
542  if ( tgt.isDataHere() ) {
543  return gof->returnOp( tgt.eref(), index );
544  } else {
545  /*
546  const OpFunc* op2 = gof->makeHopFunc(
547  HopIndex( gof->opIndex(), MooseGetHop ), index );
548  const OpFunc1Base< A* >* hop =
549  dynamic_cast< const OpFunc1Base< A* >* >( op2 );
550  */
551  cout << "Warning: LookupField::get: cannot cross nodes yet\n";
552  return A();
553  /*
554  assert( hop );
555  // Blocking function.
556  hop->op( tgt.eref(), &ret );
557  delete op2;
558  return ret;
559  */
560  }
561  }
562  cout << "LookupField::get: Warning: Field::Get conversion error for " <<
563  dest.id.path() << "." << field << endl;
564  return A();
565  }
static const OpFunc * checkSet(const string &field, ObjId &tgt, FuncId &fid)
Definition: SetGet.cpp:15
std::string path(const std::string &separator="/") const
Definition: Id.cpp:76
virtual A returnOp(const Eref &e, const L &index) const =0
Id id
Definition: ObjId.h:98
Definition: ObjId.h:20
unsigned int FuncId
Definition: header.h:42

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class L, class A>
static void LookupField< L, A >::getVec ( Id  dest,
const string &  field,
vector< L > &  index,
vector< A > &  vec 
)
inlinestatic

Blocking call that returns a vector of values in vec. This variant goes through each target object entry on dest, and passes in the same lookup index to each one. The results are put together in the vector vec.

Definition at line 573 of file SetGet.h.

References SetGet::checkSet(), Id::element(), Id::path(), Element::resize(), and LookupGetOpFuncBase< L, A >::returnOp().

575  {
576  vec.resize( 0 );
577  ObjId tgt( dest );
578  FuncId fid;
579  string fullFieldName = "get" + field;
580  fullFieldName[3] = std::toupper( fullFieldName[3] );
581  const OpFunc* func = SetGet::checkSet( fullFieldName, tgt, fid );
582  const LookupGetOpFuncBase< L, A >* gof =
583  dynamic_cast< const LookupGetOpFuncBase< L, A >* >( func );
584  if ( gof ) {
585  Element* elm = dest.element();
586  unsigned int size = vec.size(); // temporary. See SetVec.
587  vec.resize( size );
588  for ( unsigned int i = 0; i < size; ++i ) {
589  Eref e( elm, i );
590  vec[i] = gof->returnOp( e, index );
591  }
592  return;
593  }
594  cout << "Warning: Field::getVec conversion error for " <<
595  dest.path() << endl;
596  }
static const OpFunc * checkSet(const string &field, ObjId &tgt, FuncId &fid)
Definition: SetGet.cpp:15
Element * element() const
Synonym for Id::operator()()
Definition: Id.cpp:113
std::string path(const std::string &separator="/") const
Definition: Id.cpp:76
virtual A returnOp(const Eref &e, const L &index) const =0
Definition: ObjId.h:20
Definition: Eref.h:26
unsigned int FuncId
Definition: header.h:42
virtual void resize(unsigned int newNumData)=0

+ Here is the call graph for this function:

template<class L, class A>
static bool LookupField< L, A >::innerStrGet ( const ObjId dest,
const string &  field,
const string &  indexStr,
string &  str 
)
inlinestatic

Blocking virtual call for finding a value and returning in a string.

Definition at line 602 of file SetGet.h.

References Conv< T >::str2val(), and Conv< T >::val2str().

Referenced by LookupElementValueFinfo< T, L, F >::strGet(), LookupValueFinfo< T, L, F >::strGet(), ReadOnlyLookupElementValueFinfo< T, L, F >::strGet(), and ReadOnlyLookupValueFinfo< T, L, F >::strGet().

604  {
605  L index;
606  Conv< L >::str2val( index, indexStr );
607 
608  A ret = get( dest, field, index );
609  Conv<A>::val2str( str, ret );
610  return 1;
611  }
static void str2val(T &val, const string &s)
Definition: Conv.h:65
static void val2str(string &s, const T &val)
Definition: Conv.h:74

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class L, class A>
static bool LookupField< L, A >::innerStrSet ( const ObjId dest,
const string &  field,
const string &  indexStr,
const string &  val 
)
inlinestatic

Blocking call using string conversion

Definition at line 514 of file SetGet.h.

References LookupField< L, A >::set(), and Conv< T >::str2val().

Referenced by LookupElementValueFinfo< T, L, F >::strSet(), and LookupValueFinfo< T, L, F >::strSet().

516  {
517  L index;
518  Conv< L >::str2val( index, indexStr );
519 
520  A arg;
521  // Do NOT add 'set_' to the field name, as the 'set' func
522  // does it anyway.
523  Conv< A >::str2val( arg, val );
524  return set( dest, field, index, arg );
525  }
static bool set(const ObjId &dest, const string &field, L index, A arg)
Definition: SetGet.h:467
static void str2val(T &val, const string &s)
Definition: Conv.h:65

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class L, class A>
static bool LookupField< L, A >::set ( const ObjId dest,
const string &  field,
index,
arg 
)
inlinestatic

Blocking, typed 'Set' call. Identical to SetGet2::set.

Definition at line 467 of file SetGet.h.

References SetGet2< A1, A2 >::set().

Referenced by Shell::doSetClock(), LookupField< L, A >::innerStrSet(), Neuron::scaleHeadDiffusion(), testClock(), and testLookupSetGet().

469  {
470  string temp = "set" + field;
471  temp[3] = std::toupper( temp[3] );
472  return SetGet2< L, A >::set( dest, temp, index, arg );
473  }
static bool set(const ObjId &dest, const string &field, A1 arg1, A2 arg2)
Definition: SetGet.h:365

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class L, class A>
static bool LookupField< L, A >::setRepeat ( Id  destId,
const string &  field,
const vector< L > &  index,
arg 
)
inlinestatic

Faking setRepeat too. Just plugs into setVec.

Definition at line 504 of file SetGet.h.

References LookupField< L, A >::setVec().

506  {
507  vector< A > avec( index.size(), arg );
508  return setVec( destId, field, index, avec );
509  }
static bool setVec(Id destId, const string &field, const vector< L > &index, const vector< A > &arg)
Definition: SetGet.h:479

+ Here is the call graph for this function:

template<class L, class A>
static bool LookupField< L, A >::setVec ( Id  destId,
const string &  field,
const vector< L > &  index,
const vector< A > &  arg 
)
inlinestatic

This setVec assigns goes through each object entry in the destId, and assigns the corresponding index and argument to it.

Definition at line 479 of file SetGet.h.

References SetGet2< A1, A2 >::setVec().

Referenced by LookupField< L, A >::setRepeat().

481  {
482  string temp = "set" + field;
483  temp[3] = std::toupper( temp[3] );
484  return SetGet2< L, A >::setVec( destId, temp, index, arg );
485  }
static bool setVec(Id destId, const string &field, const vector< A1 > &arg1, const vector< A2 > &arg2)
Definition: SetGet.h:404

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class L, class A>
static bool LookupField< L, A >::setVec ( ObjId  dest,
const string &  field,
const vector< L > &  index,
const vector< A > &  arg 
)
inlinestatic

This setVec takes a specific object entry, presumably one with an array of values within it. The it goes through each specified index and assigns the corresponding argument. This is a brute-force assignment.

Definition at line 493 of file SetGet.h.

References SetGet2< A1, A2 >::setVec().

495  {
496  string temp = "set" + field;
497  temp[3] = std::toupper( temp[3] );
498  return SetGet2< L, A >::setVec( dest, temp, index, arg );
499  }
static bool setVec(Id destId, const string &field, const vector< A1 > &arg1, const vector< A2 > &arg2)
Definition: SetGet.h:404

+ Here is the call graph for this function:


The documentation for this class was generated from the following file: