diff options
-rw-r--r-- | project2/cache.cpp | 4 | ||||
-rw-r--r-- | project2/iHaveParameters.cpp | 18 | ||||
-rw-r--r-- | project2/iHaveParameters.h | 9 | ||||
-rw-r--r-- | project2/sqlMergeTask.cpp | 2 | ||||
-rw-r--r-- | project2/variables-modlookup.cpp | 2 | ||||
-rw-r--r-- | project2/variables.h | 2 |
6 files changed, 10 insertions, 27 deletions
diff --git a/project2/cache.cpp b/project2/cache.cpp index 32dc3c5..1dc435f 100644 --- a/project2/cache.cpp +++ b/project2/cache.cpp @@ -31,11 +31,11 @@ void Cache::applyKeys(const boost::function2<void, const std::string &, const VariableType &> & f, const IHaveParameters * ps) const { BOOST_FOREACH(const IHaveParameters::Parameters::value_type & p, allParameters()) { - f(p.first, p.second->value()); + f(p.first, p.second); } if (inherit) { BOOST_FOREACH(const IHaveParameters::Parameters::value_type & p, ps->allParameters()) { - f(p.first, p.second->value()); + f(p.first, p.second); } } } diff --git a/project2/iHaveParameters.cpp b/project2/iHaveParameters.cpp index e254a4f..e4f456a 100644 --- a/project2/iHaveParameters.cpp +++ b/project2/iHaveParameters.cpp @@ -7,11 +7,9 @@ IHaveParameters::Stack IHaveParameters::scope; IHaveParameters::IHaveParameters(const xmlpp::Element * p) { - BOOST_FOREACH(xmlpp::Node * node, p->find("parameters/param")) { - const xmlpp::Element * elem = dynamic_cast<const xmlpp::Element *>(node); - if (elem) { - ParameterPtr p = new Parameter(elem); - parameters[p->name] = p; + BOOST_FOREACH(xmlpp::Node * node, p->find("parameters/*")) { + if (const xmlpp::Element * pelem = dynamic_cast<const xmlpp::Element *>(node)) { + parameters.insert(Parameters::value_type(pelem->get_name(), Variable(pelem, boost::optional<Glib::ustring>()))); } } } @@ -20,18 +18,12 @@ IHaveParameters::~IHaveParameters() { } -IHaveParameters::Parameter::Parameter(const xmlpp::Element * p) : - name(p->get_attribute_value("name")), - value(p, "value") -{ -} - VariableType IHaveParameters::getParameter(const Glib::ustring & name) const { Parameters::const_iterator i = parameters.find(name); if (i != parameters.end()) { - return i->second->value; + return i->second; } throw ParamNotFound(name); } @@ -55,7 +47,7 @@ IHaveParameters::getScopedParameter(const Glib::ustring & name) for(Stack::const_reverse_iterator ihp = scope.rbegin(); ihp != scope.rend(); ihp++) { Parameters::const_iterator i = (*ihp)->parameters.find(name); if (i != (*ihp)->parameters.end()) { - return i->second->value; + return i->second; } } throw ParamNotFound(name); diff --git a/project2/iHaveParameters.h b/project2/iHaveParameters.h index 51378ee..28dbf7d 100644 --- a/project2/iHaveParameters.h +++ b/project2/iHaveParameters.h @@ -10,14 +10,7 @@ /// Mix-in base class to store parameters for component execution class IHaveParameters { public: - class Parameter : public virtual IntrusivePtrBase { - public: - Parameter(const xmlpp::Element * p); - const Glib::ustring name; - const Variable value; - }; - typedef boost::intrusive_ptr<Parameter> ParameterPtr; - typedef std::map<Glib::ustring, ParameterPtr> Parameters; + typedef std::map<Glib::ustring, Variable> Parameters; IHaveParameters(const xmlpp::Element * p); virtual ~IHaveParameters() = 0; diff --git a/project2/sqlMergeTask.cpp b/project2/sqlMergeTask.cpp index 2c38bf1..09657f8 100644 --- a/project2/sqlMergeTask.cpp +++ b/project2/sqlMergeTask.cpp @@ -31,7 +31,7 @@ class SqlMergeInsert : IHaveParameters, public Task { void execute() const { unsigned int col = 0; BOOST_FOREACH(const Parameters::value_type & v, parameters) { - boost::apply_visitor<const SqlVariableBinder, const VariableType>(SqlVariableBinder(insert, col++), v.second->value); + boost::apply_visitor<const SqlVariableBinder, const VariableType>(SqlVariableBinder(insert, col++), v.second); } insert->execute(); } diff --git a/project2/variables-modlookup.cpp b/project2/variables-modlookup.cpp index 026362c..85a1fbe 100644 --- a/project2/variables-modlookup.cpp +++ b/project2/variables-modlookup.cpp @@ -46,7 +46,7 @@ class VariableLookup : public VariableImplDyn, public RowProcessor { Key k; k.reserve(parameters.size()); BOOST_FOREACH(const Parameters::value_type & p, parameters) { - k.push_back(p.second->value()); + k.push_back(p.second); } return safeMapFind<NotFound>(map, k)->second; } diff --git a/project2/variables.h b/project2/variables.h index 54ac52c..6dbbf2b 100644 --- a/project2/variables.h +++ b/project2/variables.h @@ -80,7 +80,6 @@ class Variable { Variable(const xmlpp::Element *, const boost::optional<Glib::ustring> &); Variable(VariableType def); - static Variable makeFromCode(const Glib::ustring & s); static Variable makeParent(const Glib::ustring & name, bool attr, unsigned int depth); operator VariableType () const { return var->value(); } @@ -89,7 +88,6 @@ class Variable { private: Variable(VariableImpl *); friend class VariableParse; - static VariableImplPtr create(const Glib::ustring & s); VariableImplPtr var; }; |