ParameterCenter Class Reference

#include <ParameterCenter.hpp>

Inheritance diagram for ParameterCenter:

Inheritance graph
[legend]
Collaboration diagram for ParameterCenter:

Collaboration graph
[legend]

List of all members.

Public Member Functions

void get (IdentifierSet &I)
 gets the identifiers associated to parameters.
template<typename __GivenParameter>
void subscribe (__GivenParameter *gp)
ReferenceCounting
< ParametrizableObject
get (const char *parameterName)
void reset ()
template<typename t>
void set (const char *address, const t &d)
void get (const char *address, real_t &aDouble)
void get (const char *address, int &anInteger)
void get (const char *address, std::string &aString)
 ParameterCenter ()
 ~ParameterCenter ()

Static Public Member Functions

static ParameterCenterinstance ()
static void create ()
static void destroy ()

Static Protected Attributes

static ParameterCenter__pInstance

Private Types

typedef std::map< const char
*, ReferenceCounting
< ParametrizableObject >
, StringEquality
ParameterSet

Private Member Functions

ReferenceCounting< ParametergetParameter (const char *address)

Private Attributes

ParameterSet __parametersSet


Detailed Description

Definition at line 39 of file ParameterCenter.hpp.


Member Typedef Documentation

Definition at line 45 of file ParameterCenter.hpp.


Constructor & Destructor Documentation

ParameterCenter::ParameterCenter (  )  [inline, explicit]

Definition at line 96 of file ParameterCenter.hpp.

00097   {
00098     ;
00099   }

ParameterCenter::~ParameterCenter (  )  [inline]

Definition at line 101 of file ParameterCenter.hpp.

00102   {
00103     ;
00104   }


Member Function Documentation

ReferenceCounting< Parameter > ParameterCenter::getParameter ( const char *  address  )  [private]

Definition at line 24 of file ParameterCenter.cpp.

References __parametersSet, fferr(), and ErrorHandler::normal.

Referenced by get(), and set().

00025 {
00026   std::string a = address;
00027   typedef std::list<std::string> StringList;
00028   StringList name;
00029 
00030   size_t begin = 0;
00031   size_t end = begin;
00032   do {
00033     end = a.find("::", begin);
00034     name.push_back(a.substr(begin,end-begin));
00035     if (end <= a.size()) {
00036       begin = end + 2;
00037     } else {
00038       break;
00039     }
00040   } while (true);
00041 
00042   if(name.size()>2) {
00043     fferr(2) << '\n' << __FILE__ << ':' << __LINE__ << ": not implemented\n";
00044   }
00045   StringList::iterator iName = name.begin();
00046   ParameterSet::iterator object = __parametersSet.find((*iName).c_str());
00047   if(object != __parametersSet.end()) {
00048     ++iName;
00049     ReferenceCounting<Parameter> p = (*(*object).second).get((*iName).c_str());
00050     return p;
00051   } else {
00052     std::stringstream errorMsg;
00053     errorMsg << "no option named " << *iName << '\n'
00054              << "availables options are:";
00055     for(object = __parametersSet.begin();
00056         object !=  __parametersSet.end(); ++object) {
00057       errorMsg << (*object).first << std::ends;
00058     }
00059 
00060     throw ErrorHandler(__FILE__,__LINE__,
00061                        errorMsg.str(),
00062                        ErrorHandler::normal);
00063     return 0;
00064   }
00065 }

Here is the call graph for this function:

void ParameterCenter::get ( IdentifierSet I  ) 

gets the identifiers associated to parameters.

Definition at line 123 of file ParameterCenter.cpp.

References __parametersSet.

Referenced by FFLexer::FFLexer(), and GetParameter< FatBoundaryOptions >::GetParameter().

00124 {
00125   for (ParameterCenter::ParameterSet::iterator i = __parametersSet.begin();
00126        i != __parametersSet.end(); ++i) {
00127     I.insert((*i).first);
00128     (*(*i).second).get(I);
00129   }
00130 }

template<typename __GivenParameter>
void ParameterCenter::subscribe ( __GivenParameter *  gp  )  [inline]

Definition at line 56 of file ParameterCenter.hpp.

References __parametersSet.

Referenced by ParametersInitialization::ParametersInitialization().

00057   {
00058     __parametersSet[__GivenParameter::identifier()]
00059       = dynamic_cast<ParametrizableObject*>(gp);
00060   }

ReferenceCounting<ParametrizableObject> ParameterCenter::get ( const char *  parameterName  )  [inline]

Definition at line 62 of file ParameterCenter.hpp.

References __parametersSet, and ErrorHandler::normal.

00063   {
00064     ParameterSet::iterator i = __parametersSet.find(parameterName);
00065     if (i != __parametersSet.end()) {
00066       return (*i).second;
00067     } else {
00068       std::stringstream errorMsg;
00069       errorMsg << "'" << parameterName << "' not found!\n";
00070       errorMsg << "List of parameters:\n";
00071       for (i = __parametersSet.begin(); i !=  __parametersSet.end();
00072            ++i) {
00073         errorMsg << '\t' << (*i).first << '\n';
00074       }
00075       errorMsg << std::ends;
00076       throw ErrorHandler(__FILE__,__LINE__,
00077                          errorMsg.str(),
00078                          ErrorHandler::normal);
00079     }
00080     return 0;
00081   }

void ParameterCenter::reset (  ) 

Definition at line 115 of file ParameterCenter.cpp.

References __parametersSet.

Referenced by SolverExpression::execute().

00116 {
00117   for(ParameterSet::iterator i = __parametersSet.begin();
00118       i != __parametersSet.end(); ++i) {
00119     (*(*i).second).reset();
00120   }
00121 }

template<typename t>
void ParameterCenter::set ( const char *  address,
const t &  d 
) [inline]

void ParameterCenter::get ( const char *  address,
real_t &  aDouble 
)

Definition at line 67 of file ParameterCenter.cpp.

References Parameter::Double, getParameter(), ErrorHandler::normal, and stringify().

00068 {
00069   ReferenceCounting<Parameter> p = getParameter(address);
00070   switch ((*p).type()) {
00071   case Parameter::Double: {
00072     d = static_cast<real_t&>(dynamic_cast<DoubleParameter&>(*p));
00073     break;
00074   }
00075   default: {
00076     throw ErrorHandler(__FILE__,__LINE__,
00077                        "wrong parameter type reading "+stringify(address),
00078                        ErrorHandler::normal);
00079   }
00080   }
00081 }

Here is the call graph for this function:

void ParameterCenter::get ( const char *  address,
int &  anInteger 
)

Definition at line 83 of file ParameterCenter.cpp.

References Parameter::Double, getParameter(), ErrorHandler::normal, and stringify().

00084 {
00085   ReferenceCounting<Parameter> p = getParameter(address);
00086   switch ((*p).type()) {
00087   case Parameter::Double: {
00088     integer = static_cast<int&>(dynamic_cast<IntegerParameter&>(*p));
00089     break;
00090   }
00091   default: {
00092     throw ErrorHandler(__FILE__,__LINE__,
00093                        "wrong parameter type reading "+stringify(address),
00094                        ErrorHandler::normal);
00095   }
00096   }
00097 }

Here is the call graph for this function:

void ParameterCenter::get ( const char *  address,
std::string &  aString 
)

Definition at line 99 of file ParameterCenter.cpp.

References getParameter(), ErrorHandler::normal, Parameter::String, and stringify().

00100 {
00101   ReferenceCounting<Parameter> p = getParameter(address);
00102   switch ((*p).type()) {
00103   case Parameter::String: {
00104     aString = static_cast<std::string&>(dynamic_cast<StringParameter&>(*p));
00105     break;
00106   }
00107   default: {
00108     throw ErrorHandler(__FILE__,__LINE__,
00109                        "wrong parameter type reading "+stringify(address),
00110                        ErrorHandler::normal);
00111   }
00112   }
00113 }

Here is the call graph for this function:

static ParameterCenter & StaticBase< ParameterCenter >::instance (  )  [inline, static, inherited]

static void StaticBase< ParameterCenter >::create (  )  [inline, static, inherited]

Creates __pInstance in Embedding class.

Definition at line 55 of file StaticBase.hpp.

Referenced by ThreadStaticCenter::ThreadStaticCenter().

00056   {
00057     __pInstance = new EmbeddingClass();
00058   }

static void StaticBase< ParameterCenter >::destroy (  )  [inline, static, inherited]

Destroyes __autoInstanciated in Embedding class.

Definition at line 64 of file StaticBase.hpp.

Referenced by ThreadStaticCenter::~ThreadStaticCenter().

00065   {
00066     delete __pInstance;
00067   }


Member Data Documentation

Definition at line 46 of file ParameterCenter.hpp.

Referenced by get(), getParameter(), reset(), and subscribe().

ParameterCenter * StaticBase< ParameterCenter >::__pInstance [static, protected, inherited]

The static variable

Definition at line 37 of file StaticBase.hpp.


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

Generated on Wed Nov 19 00:11:13 2008 for FreeFEM3D (aka ff3d) by  doxygen 1.5.6