9 #ifndef _fei_ParameterSet_hpp_
10 #define _fei_ParameterSet_hpp_
12 #include "fei_macros.hpp"
13 #include "fei_Param.hpp"
67 bool maintain_unique_keys=
true);
76 const Param*
get(
const char* name)
const;
86 dummyParam_((const char*)NULL, (const char*)NULL),
90 : paramarray_(params), dummyParam_((const char*)NULL, (const char*)NULL),
94 if (params->empty()) {paramarray_ = NULL; offset_ = 0;}
104 if (paramarray_ == NULL)
return(dummyParam_);
105 if (offset_ >= paramarray_->size())
return(dummyParam_);
106 return( *((*paramarray_)[offset_]) );
112 if (paramarray_ != NULL) {
113 if (offset_ < paramarray_->
size()) {
116 if (offset_ == paramarray_->size()) {
127 paramarray_ = src.paramarray_;
128 offset_ = src.offset_;
135 return( paramarray_ == rhs.paramarray_ && offset_ == rhs.offset_ );
141 return( !(*
this == rhs) );
145 std::vector<const fei::Param*>* paramarray_;
151 const_iterator
begin()
const;
154 const_iterator
end()
const;
160 int& paramValue)
const;
167 double& paramValue)
const;
173 std::string& paramValue)
const;
179 bool& paramValue)
const;
185 const void*& paramValue)
const;
188 int findOffset(
const fei::Param* param)
const;
189 int findOffset(
const char* name)
const;
190 std::vector<const Param*>* params_;
196 int fei::ParameterSet::findOffset(
const char* name)
const
198 if (params_->empty() || name == NULL)
return( -1 );
200 std::vector<const Param*>::const_iterator
201 p_iter = params_->begin(),
202 p_end = params_->end();
205 for(; p_iter != p_end; ++p_iter, ++i) {
206 const Param* prm = *p_iter;
207 if (prm->getName() == name) {
215 int fei::ParameterSet::findOffset(
const fei::Param* param)
const
217 if (param == NULL)
return( -1 );
219 return( findOffset( param->
getName().c_str() ) );
237 int index = findOffset(¶m);
240 params_->push_back(newparam);
243 if (maintain_unique_keys) {
244 delete (*params_)[index];
245 (*params_)[index] = newparam;
248 params_->push_back(newparam);
256 return( params_->size() );
262 if (params_ == NULL)
return(NULL);
264 int index = findOffset(name);
265 if (index < 0)
return(NULL);
266 return( (*params_)[index] );
const Param * get(const char *name) const
int getVoidParamValue(const char *name, const void *¶mValue) const
bool operator==(const const_iterator &rhs)
int getBoolParamValue(const char *name, bool ¶mValue) const
int getStringParamValue(const char *name, std::string ¶mValue) const
bool operator!=(const const_iterator &rhs)
void add(const Param ¶m, bool maintain_unique_keys=true)
int getDoubleParamValue(const char *name, double ¶mValue) const
const_iterator & operator++()
const Param & operator*() const
const_iterator(int offset, std::vector< const Param * > *params)
const std::string & getName() const
const_iterator end() const
const_iterator & operator=(const const_iterator &src)
const_iterator begin() const
int getIntParamValue(const char *name, int ¶mValue) const