diff --git a/vlsisapd/src/configuration/src/CMakeLists.txt b/vlsisapd/src/configuration/src/CMakeLists.txt index c10a50bb..856f9bca 100644 --- a/vlsisapd/src/configuration/src/CMakeLists.txt +++ b/vlsisapd/src/configuration/src/CMakeLists.txt @@ -19,6 +19,7 @@ set ( includes vlsisapd/configuration/Parameter.h vlsisapd/configuration/LayoutDescription.h vlsisapd/configuration/Configuration.h + vlsisapd/configuration/BoostPythonStlWrappers.h ) set ( cpps Parameter.cpp LayoutDescription.cpp diff --git a/vlsisapd/src/configuration/src/ConfEditorMain.cpp b/vlsisapd/src/configuration/src/ConfEditorMain.cpp index 73209091..bf6e8d37 100644 --- a/vlsisapd/src/configuration/src/ConfEditorMain.cpp +++ b/vlsisapd/src/configuration/src/ConfEditorMain.cpp @@ -91,10 +91,10 @@ int main ( int argc, char* argv[] ) conf->readFromFile ( dotConfPath.string() ); } - cout << "misc.catchCore: " << conf->getParameter("misc.catchCore" )->asBool() << endl; - cout << "kite.eventsLimit: " << conf->getParameter("kite.eventsLimit")->asInt () << endl; + //cout << "misc.catchCore: " << conf->getParameter("misc.catchCore" )->asBool() << endl; + //cout << "kite.eventsLimit: " << conf->getParameter("kite.eventsLimit")->asInt () << endl; - bfs::path pyDotConfPath ( "./.coriolis2.init.py" ); + bfs::path pyDotConfPath ( "./.coriolis2.configuration.py" ); if ( bfs::exists(pyDotConfPath) ) { cout << "Reading python dot configuration: <" << pyDotConfPath.string() << ">." << endl; Py_Initialize (); diff --git a/vlsisapd/src/configuration/src/ConfEditorWidget.cpp b/vlsisapd/src/configuration/src/ConfEditorWidget.cpp index 1baf0e7e..621ef010 100644 --- a/vlsisapd/src/configuration/src/ConfEditorWidget.cpp +++ b/vlsisapd/src/configuration/src/ConfEditorWidget.cpp @@ -87,8 +87,8 @@ namespace Cfg { cout << "Saving configuration file: <" << dotConfigFile << ">."<< endl; //Configuration::get()->writeToStream ( file, 0, ";misc;kite;;mauka;;" ); - Configuration::get()->writeToStream ( file, Configuration::DriveValues|Configuration::DriveLayout, "misc" ); - //Configuration::get()->writeToStream ( file, 0 ); + //Configuration::get()->writeToStream ( file, Configuration::DriveValues|Configuration::DriveLayout, "misc" ); + Configuration::get()->writeToStream ( file, 0 ); //Configuration::get()->writeToStream ( file, Configuration::DriveValues|Configuration::DriveLayout ); file.close (); } diff --git a/vlsisapd/src/configuration/src/Configuration.cpp b/vlsisapd/src/configuration/src/Configuration.cpp index cd74d916..1b14014a 100644 --- a/vlsisapd/src/configuration/src/Configuration.cpp +++ b/vlsisapd/src/configuration/src/Configuration.cpp @@ -147,6 +147,7 @@ namespace { ); } else { _parameter->setString ( _getAttributeValue("value") + , Configuration::getDefaultPriority() , (Parameter::AllRequirements | Parameter::FromString) & ~Parameter::TypeCheck ); diff --git a/vlsisapd/src/configuration/src/ConfigurationWidget.cpp b/vlsisapd/src/configuration/src/ConfigurationWidget.cpp index 9d791a53..84b4f90e 100644 --- a/vlsisapd/src/configuration/src/ConfigurationWidget.cpp +++ b/vlsisapd/src/configuration/src/ConfigurationWidget.cpp @@ -140,7 +140,7 @@ namespace Cfg { { ParameterWidget* pw = find(parameter); if ( pw != NULL ) { - cerr << "[ERROR] Parameter <" << parameter->getId() << "> already added." << endl; + cerr << "[ERROR] ParameterWidget for <" << parameter->getId() << "> already added." << endl; return pw; } diff --git a/vlsisapd/src/configuration/src/LayoutDescription.cpp b/vlsisapd/src/configuration/src/LayoutDescription.cpp index 63dd2d09..d0f77257 100644 --- a/vlsisapd/src/configuration/src/LayoutDescription.cpp +++ b/vlsisapd/src/configuration/src/LayoutDescription.cpp @@ -129,6 +129,9 @@ namespace Cfg { case WidgetDescription::Parameter: Parameter* parameter = _configuration->getParameter ( widgets[iwidget]->getId() ); if ( parameter ) { + // cerr << "WidgetDescription::Parameter: " << (void*)widgets[iwidget] + // << " " << widgets[iwidget]->getId() + // << " " << (void*)parameter << endl; cw->addParameter ( _tabs[itab]->getName() , parameter , widgets[iwidget]->getLabel() diff --git a/vlsisapd/src/configuration/src/Parameter.cpp b/vlsisapd/src/configuration/src/Parameter.cpp index 865ce3ab..d0302a56 100644 --- a/vlsisapd/src/configuration/src/Parameter.cpp +++ b/vlsisapd/src/configuration/src/Parameter.cpp @@ -100,7 +100,7 @@ namespace Cfg { } if ( priority == UseDefault ) _priority = getDefaultPriority(); - //cerr << "New " << typeToString(_type) << " parameter " << _id << " value:" << _value << endl; + //cerr << "New " << (void*)this << " " << typeToString(_type) << " parameter " << _id << " value:" << _value << endl; } @@ -162,10 +162,11 @@ namespace Cfg { } - bool Parameter::setString ( const std::string& s, unsigned int flags, Priority priority ) + bool Parameter::setString ( const std::string& s, Priority priority, unsigned int flags ) { if ( not _updatePriority(priority) ) return false; + flags |= _flags; if ( (flags & TypeCheck) and (_type != String) ) cerr << "[ERROR] Parameter::setString(): Setting " << Parameter::typeToString(_type) << " parameter <" << _id @@ -184,7 +185,7 @@ namespace Cfg { << " parameter <" << _id << "> as " << Parameter::typeToString(Bool)<< " (type mismatch)." << endl; - return _doChange ( AllRequirements, "", b, 0, 0.0 ); + return _doChange ( _flags, "", b, 0, 0.0 ); } @@ -197,7 +198,7 @@ namespace Cfg { << " parameter <" << _id << "> as " << Parameter::typeToString(Int)<< " (type mismatch)." << endl; - return _doChange ( AllRequirements, "", false, i, 0.0 ); + return _doChange ( _flags, "", false, i, 0.0 ); } @@ -210,7 +211,7 @@ namespace Cfg { << " parameter <" << _id << "> as " << Parameter::typeToString(Double)<< " (type mismatch)." << endl; - return _doChange ( AllRequirements, "", false, 0, d ); + return _doChange ( _flags, "", false, 0, d ); } @@ -223,7 +224,7 @@ namespace Cfg { << " parameter <" << _id << "> as " << Parameter::typeToString(Double)<< " (type mismatch)." << endl; - return _doChange ( AllRequirements, "", false, 0, d ); + return _doChange ( _flags, "", false, 0, d ); } @@ -255,7 +256,8 @@ namespace Cfg { bool Parameter::_doChange ( unsigned int flags, const string& s, bool b, int i, double d ) { - //cerr << "_doChange: " << _id << ":" << _value << " -> \"" << s << "\"|" << b << "|" << i << "|" << d; + //cerr << "_doChange: " << _id << ":" << _value << " -> \"" << s << "\"|" << b << "|" << i << "|" << d + // << " [" << _flags << "]"; Configuration* configuration = Configuration::get(); ostringstream svalue; @@ -296,15 +298,17 @@ namespace Cfg { } if ( (flags & NeedRestart) and hasFlags(NeedRestart) ) { + //cerr << " needrestart"; configuration->addLog ( Configuration::LogRestart, _id ); } if ( (flags & MustExist) and hasFlags(MustExist) ) { if ( _type == String ) { bfs::path filePath = ( svalue.str() ); - if ( not bfs::exists(filePath) ) + if ( not bfs::exists(filePath) ) { + //cerr << " needrestart" << _id << endl; configuration->addLog ( Configuration::LogNeedExist, _id ); - else + } else configuration->removeLog ( Configuration::LogNeedExist, _id ); } } diff --git a/vlsisapd/src/configuration/src/PyConfiguration.cpp b/vlsisapd/src/configuration/src/PyConfiguration.cpp index eef7b5f5..84b6eef9 100644 --- a/vlsisapd/src/configuration/src/PyConfiguration.cpp +++ b/vlsisapd/src/configuration/src/PyConfiguration.cpp @@ -19,103 +19,143 @@ // +-----------------------------------------------------------------+ -#include -#include +#include +#include "vlsisapd/configuration/BoostPythonStlWrappers.h" +#include "vlsisapd/configuration/Configuration.h" +#include "vlsisapd/configuration/ParameterWidget.h" using namespace boost::python; -#include "vlsisapd/openChams/PySTLMapWrapper.h" -using OpenChams::map_item; - -#include "vlsisapd/configuration/Configuration.h" - namespace { using namespace Cfg; - template - struct EnumToInt { - static PyObject* convert ( EnumType& type ) - { return incref ( object((int)type).ptr() ); } - }; - - // Thin wrappers for function members overloads. - void parameterSetMinInt1 ( Parameter& self, int min ) { self.setMin(min); } - void parameterSetMinDouble1 ( Parameter& self, double min ) { self.setMin(min); } - void parameterSetMaxInt1 ( Parameter& self, int max ) { self.setMax(max); } - void parameterSetMaxDouble1 ( Parameter& self, double max ) { self.setMax(max); } + bool paramSetString1 ( Parameter& self, const std::string& value ) + { return self.setString(value); } -// STL map wrapper for boost::python. - template - class MapWrapper { - public: - typedef typename Map::key_type Key; - typedef typename Map::mapped_type Value; - public: - static Value& get ( Map&, const Key& ); - static void set ( Map&, const Key&, const Value& ); - static void del ( Map&, const Key& ); - static bool in ( Map&, const Key& ); - static list keys ( Map& ); - static list values ( Map& ); - static list items ( Map& ); - }; + bool paramSetString2 ( Parameter& self, const std::string& value, unsigned int flags ) + { return self.setString(value,Configuration::getDefaultPriority(),flags); } + bool paramSetString3 ( Parameter& self, const std::string& value, unsigned int flags, Parameter::Priority pri ) + { return self.setString(value,pri,flags); } - inline void KeyError () { PyErr_SetString(PyExc_KeyError, "Key not found"); } + bool paramSetBool1 ( Parameter& self, bool value ) { return self.setBool(value); } + bool paramSetInt1 ( Parameter& self, int value ) { return self.setInt(value); } + bool paramSetDouble1 ( Parameter& self, double value ) { return self.setDouble(value); } + bool paramSetPercentage1 ( Parameter& self, double value ) { return self.setPercentage(value); } - - template - typename MapWrapper::Value& MapWrapper::get ( Map& m, const typename MapWrapper::Key& k ) + bool paramSetBool2 ( Parameter& self, bool value, Parameter::Priority pri ) { return self.setBool(value,pri); } + bool paramSetInt2 ( Parameter& self, int value, Parameter::Priority pri ) { return self.setInt(value,pri); } + bool paramSetDouble2 ( Parameter& self, double value, Parameter::Priority pri ) { return self.setDouble(value,pri); } + bool paramSetPercentage2 ( Parameter& self, double value, Parameter::Priority pri ) { return self.setPercentage(value,pri); } + + void paramSetMinInt1 ( Parameter& self, int min ) { self.setMin(min); } + void paramSetMinDouble1 ( Parameter& self, double min ) { self.setMin(min); } + void paramSetMaxInt1 ( Parameter& self, int max ) { self.setMax(max); } + void paramSetMaxDouble1 ( Parameter& self, double max ) { self.setMax(max); } + + std::string reprParameter ( const Parameter* p ) { - static Value notFound; - if( m.find(k) != m.end() ) return m[k]; - KeyError (); - return notFound; + std::ostringstream repr; + repr << "getId() + << "\" type=\"" << Parameter::typeToString(p->getType()) + << "\" value=\""; + + if ( p->getType() == Parameter::Percentage ) repr << p->asPercentageString(); + else repr << p->asString(); + + repr << "\">"; + + return repr.str(); } - template - void MapWrapper::set ( Map& m, const MapWrapper::Key& k, const typename MapWrapper::Value& v ) - { m[k] = v; } - template - void MapWrapper::del ( Map& m, const typename MapWrapper::Key& k) - { - if( m.find(k) != m.end() ) m.erase(k); - else KeyError (); - } + void layoutAddTab ( LayoutDescription& self + , const std::string& tabName + , const std::string& id + ) + { self.addTab(tabName,id); } - template - bool MapWrapper::in ( Map& m, const typename MapWrapper::Key& k ) - { return m.find(k) != m.end(); } - template - list MapWrapper::keys ( Map& m ) - { - list l; - for(typename Map::iterator it = m.begin() ; it != m.end() ; ++it ) - l.append ( it->first ); - return l; - } + void layoutAddSection2 ( LayoutDescription& self + , const std::string& tabName + , const std::string& section + ) + { self.addSection(tabName,section); }; - template - list MapWrapper::values ( Map& m) - { - list l; - for( typename Map::iterator it=m.begin(); it != m.end() ; ++it ) - l.append ( it->second ); - return l; - } - template - list MapWrapper::items ( Map& m ) { - list l; - for( typename Map::iterator it=m.begin(); it!=m.end(); ++it ) - l.append( make_tuple(it->first,it->second) ); - return l; - } + void layoutAddSection3 ( LayoutDescription& self + , const std::string& tabName + , const std::string& section + , int column + ) + { self.addSection(tabName,section,column); }; + + + void layoutAddParameter3 ( LayoutDescription& self + , const std::string& tabName + , const std::string& id + , const std::string& label + ) + { self.addParameter(tabName,id,label); }; + + + void layoutAddParameter4 ( LayoutDescription& self + , const std::string& tabName + , const std::string& id + , const std::string& label + , int column + ) + { self.addParameter(tabName,id,label,column); }; + + + void layoutAddParameter5 ( LayoutDescription& self + , const std::string& tabName + , const std::string& id + , const std::string& label + , int column + , int span + ) + { self.addParameter(tabName,id,label,column,span); }; + + + void layoutAddParameter6 ( LayoutDescription& self + , const std::string& tabName + , const std::string& id + , const std::string& label + , int column + , int span + , unsigned int flags + ) + { self.addParameter(tabName,id,label,column,span,flags); }; + + Parameter* cfgGetParameter1 ( const Configuration& self, const std::string& id ) + { return self.getParameter(id); } + + Parameter* cfgGetParameter2 ( const Configuration& self, const std::string& id, Parameter::Type type ) + { return self.getParameter(id,type); } + + Parameter* cfgAddParameter2 ( Configuration& self, const std::string& id, Parameter::Type type, const std::string& value ) + { return self.addParameter(id,type,value); } + + Parameter* cfgAddParameter3 ( Configuration& self, const std::string& id, Parameter::Type type, const std::string& value, Parameter::Priority pri ) + { return self.addParameter(id,type,value,pri); } + + Parameter* getParamString1 ( const std::string& id ) { return getParamString(id); } + Parameter* getParamBool1 ( const std::string& id ) { return getParamBool(id); } + Parameter* getParamInt1 ( const std::string& id ) { return getParamInt(id); } + Parameter* getParamEnumerate1 ( const std::string& id ) { return getParamEnumerate(id); } + Parameter* getParamDouble1 ( const std::string& id ) { return getParamDouble(id); } + Parameter* getParamPercentage1 ( const std::string& id ) { return getParamPercentage(id); } + + Parameter* getParamString2 ( const std::string& id, const std::string& value ) { return getParamString(id,value); } + Parameter* getParamInt2 ( const std::string& id, int value ) { return getParamInt(id,value); } + Parameter* getParamEnumerate2 ( const std::string& id, int value ) { return getParamEnumerate(id,value); } + Parameter* getParamBool2 ( const std::string& id, bool value ) { return getParamBool(id,value); } + Parameter* getParamDouble2 ( const std::string& id, double value ) { return getParamDouble(id,value); } + Parameter* getParamPercentage2 ( const std::string& id, double value ) { return getParamPercentage(id,value); } } // End of anonymous namespace. @@ -126,6 +166,9 @@ namespace Cfg { BOOST_PYTHON_MODULE(Cfg) { + VectorWrapper< std::vector >::wrap ( "StringVector" ); + VectorWrapper< std::vector >::wrap ( "EnumValueVector" ); + typedef void (Parameter::* VoidIntPrioritySign )(int ,Parameter::Priority) ; typedef void (Parameter::* VoidDoublePrioritySign )(double,Parameter::Priority) ; typedef void (Parameter::* VoidIntSign )(int ); @@ -141,73 +184,74 @@ namespace Cfg { // Parameter overloaded function members. BoolIntConstSign paramCheckValueInt = (BoolIntConstSign) &Parameter::checkValue; BoolDoubleConstSign paramCheckValueDouble = (BoolDoubleConstSign)&Parameter::checkValue; - BoolStringSign paramSetString1 = (BoolStringSign) &Parameter::setString; - BoolStringFlagsSign paramSetString2 = (BoolStringFlagsSign)&Parameter::setString; - BoolBoolSign paramSetBool1 = (BoolBoolSign) &Parameter::setBool; - BoolIntSign paramSetInt1 = (BoolIntSign) &Parameter::setInt; - BoolDoubleSign paramSetDouble1 = (BoolDoubleSign) &Parameter::setDouble; - BoolDoubleSign paramSetPercentage1 = (BoolDoubleSign) &Parameter::setPercentage; implicitly_convertible(); implicitly_convertible(); implicitly_convertible(); - //to_python_converter >(); + //to_python_converter >(); { scope paramScope ( class_("Parameter", init >()) - .def("isFile" , &Parameter::isFile) - .def("isPath" , &Parameter::isPath) - .def("hasMin" , &Parameter::hasMin) - .def("hasMax" , &Parameter::hasMax) - .def("hasNeedRestart" , &Parameter::hasNeedRestart) - .def("hasMustExist" , &Parameter::hasMustExist) - //.def("hasFlags" , &Parameter::hasFlags) - .def("getId" , &Parameter::getId, return_value_policy()) - .def("getMinInt" , &Parameter::getMinInt) - .def("getMaxInt" , &Parameter::getMaxInt) - .def("getMinDouble" , &Parameter::getMinDouble) - .def("getMaxDouble" , &Parameter::getMaxDouble) - .def("checkValue" , paramCheckValueInt) - .def("checkValue" , paramCheckValueDouble) - .def("asString" , &Parameter::asString, return_value_policy()) - .def("asPercentageString", &Parameter::asPercentageString) - .def("asBool" , &Parameter::asBool) - .def("asInt" , &Parameter::asInt) - .def("asPercentage" , &Parameter::asPercentage) - .def("addValue" , &Parameter::addValue) - .def("addSlave" , &Parameter::addSlave) - .def("setPriority" , &Parameter::setPriority) - .def("setString" , &Parameter::setString) - .def("setString" , paramSetString1) - .def("setString" , paramSetString2) - .def("setBool" , &Parameter::setBool) - .def("setBool" , paramSetBool1) - .def("setInt" , &Parameter::setInt) - .def("setInt" , paramSetInt1) - .def("setDouble" , &Parameter::setDouble) - .def("setDouble" , paramSetDouble1) - .def("setPercentage" , &Parameter::setPercentage) - .def("setPercentage" , paramSetPercentage1) - .def("setMin" , ¶meterSetMinInt1) - .def("setMin" , ¶meterSetMinDouble1) - .def("setMax" , ¶meterSetMaxInt1) - .def("setMax" , ¶meterSetMaxDouble1) + .def("__repr__" , reprParameter) + .def("isFile" , &Parameter::isFile) + .def("isPath" , &Parameter::isPath) + .def("hasMin" , &Parameter::hasMin) + .def("hasMax" , &Parameter::hasMax) + .def("hasNeedRestart" , &Parameter::hasNeedRestart) + .def("hasMustExist" , &Parameter::hasMustExist) + .def("hasFlags" , &Parameter::hasFlags) + .def("getId" , &Parameter::getId, return_value_policy()) + .def("getMinInt" , &Parameter::getMinInt) + .def("getMaxInt" , &Parameter::getMaxInt) + .def("getMinDouble" , &Parameter::getMinDouble) + .def("getMaxDouble" , &Parameter::getMaxDouble) + .def("checkValue" , paramCheckValueInt) + .def("checkValue" , paramCheckValueDouble) + .def("asString" , &Parameter::asString, return_value_policy()) + .def("asPercentageString", &Parameter::asPercentageString) + .def("asBool" , &Parameter::asBool) + .def("asInt" , &Parameter::asInt) + .def("asPercentage" , &Parameter::asPercentage) + .def("getSlaves" , &Parameter::getSlaves, return_value_policy()) + .def("getValues" , &Parameter::getValues, return_value_policy()) + .def("addValue" , &Parameter::addValue) + .def("addSlave" , &Parameter::addSlave) + .def("setPriority" , &Parameter::setPriority) + .def("setString" , paramSetString1) + .def("setString" , paramSetString2) + .def("setString" , paramSetString3) + .def("setBool" , paramSetBool1) + .def("setBool" , paramSetBool2) + .def("setInt" , paramSetInt1) + .def("setInt" , paramSetInt2) + .def("setDouble" , paramSetDouble1) + .def("setDouble" , paramSetDouble2) + .def("setPercentage" , paramSetPercentage1) + .def("setPercentage" , paramSetPercentage2) + .def("setMin" , paramSetMinInt1) + .def("setMin" , paramSetMinDouble1) + .def("setMax" , paramSetMaxInt1) + .def("setMax" , paramSetMaxDouble1) + .add_property("flags", &Parameter::getFlags, &Parameter::setFlags) + .add_property("type" , &Parameter::getType) + ); - //.add_property("flags", &Parameter::getFlags, &Parameter::setFlags) - .add_property("type" , &Parameter::getType) - ); + class_("Parameter::EnumValue",init()) + .def_readonly("label",&Parameter::EnumValue::_label) + .def_readonly("value",&Parameter::EnumValue::_value) + ; enum_("Type") - .value("Unknown" ,Parameter::Unknown) - .value("String" ,Parameter::String) - .value("Bool" ,Parameter::Bool) - .value("Int" ,Parameter::Int) - .value("Enumerate" ,Parameter::Enumerate) - .value("Double" ,Parameter::Double) - .value("Percentage",Parameter::Percentage) + .value("Unknown" ,Parameter::Unknown) + .value("String" ,Parameter::String) + .value("Bool" ,Parameter::Bool) + .value("Int" ,Parameter::Int) + .value("Enumerate" ,Parameter::Enumerate) + .value("Double" ,Parameter::Double) + .value("Percentage",Parameter::Percentage) ; enum_("Priority") @@ -231,40 +275,45 @@ namespace Cfg { ; } + { + scope layoutScope + ( class_("LayoutDescription", no_init) + .def("addTab" , layoutAddTab) + .def("addRule" , &LayoutDescription::addRule) + .def("addTitle" , &LayoutDescription::addTitle) + .def("addSection" , layoutAddSection2) + .def("addSection" , layoutAddSection3) + .def("addParameter", layoutAddParameter3) + .def("addParameter", layoutAddParameter4) + .def("addParameter", layoutAddParameter5) + .def("addParameter", layoutAddParameter6) + ); + } + typedef std::map ParametersMap; typedef std::pair ParametersPair; - class_("ParametersPair") - .def_readonly ("key" , &ParametersPair::first ) - .def_readwrite("value", &ParametersPair::second) - ; - class_("ParametersMap") - .def("__len__" , &ParametersMap::size) - .def("clear" , &ParametersMap::clear) - .def("__getitem__" , &MapWrapper::get, return_value_policy()) - .def("__setitem__" , &MapWrapper::set, return_value_policy()) - .def("__delitem__" , &MapWrapper::del) - .def("__contains__" , &MapWrapper::in ) - .def("has_key" , &MapWrapper::in ) - .def("keys" , &MapWrapper::keys ) - .def("values" , &MapWrapper::values ) - .def("items" , &MapWrapper::items ) - ; + PairWrapper::wrap ( "ParametersPair", "key", "value" ); + MapWrapper ::wrap ( "ParametersMap" ); // Configuration overloaded function members. - Parameter* (Configuration::*CfgGetParameter1) ( const std::string& ) const = (Parameter* (Configuration:: *)(const std::string&) const) &Configuration::getParameter; - Parameter* (Configuration::*CfgGetParameter2) ( const std::string&, Parameter::Type ) const = (Parameter* (Configuration:: *)(const std::string&,Parameter::Type) const)&Configuration::getParameter; + typedef LayoutDescription& (Configuration::* LayoutVoidSign )(); + + LayoutVoidSign CfgGetLayout0 = (LayoutVoidSign)&Configuration::getLayout; { scope confScope ( class_("Configuration", no_init) .def("get" , &Configuration::get , return_value_policy()) - .def("getParameter" , CfgGetParameter1 , return_value_policy()) - .def("getParameter" , CfgGetParameter2 , return_value_policy()) + .def("getParameter" , cfgGetParameter1 , return_value_policy()) + .def("getParameter" , cfgGetParameter2 , return_value_policy()) + .def("addParameter" , cfgAddParameter2 , return_value_policy()) + .def("addParameter" , cfgAddParameter3 , return_value_policy()) .def("pushDefaultPriority", &Configuration::pushDefaultPriority) .def("popDefaultPriority" , &Configuration::popDefaultPriority ) .def("getDefaultPriority" , &Configuration::getDefaultPriority ) .def("getParameters" , &Configuration::getParameters , return_value_policy()) + .def("getLayout" , CfgGetLayout0 , return_value_policy()) .staticmethod("get") .staticmethod("pushDefaultPriority") .staticmethod("popDefaultPriority") @@ -280,27 +329,6 @@ namespace Cfg { ; } - - // Configuration overloaded functions. - typedef Parameter* (*ParamStringSign )(const std::string&); - typedef Parameter* (*ParamStringBoolSign )(const std::string&, bool); - typedef Parameter* (*ParamStringIntSign )(const std::string&, int); - typedef Parameter* (*ParamStringDoubleSign)(const std::string&, double); - typedef Parameter* (*ParamStringStringSign)(const std::string&, const std::string&); - - ParamStringSign getParamString1 = (ParamStringSign )getParamString; - ParamStringStringSign getParamString2 = (ParamStringStringSign)getParamString; - ParamStringSign getParamBool1 = (ParamStringSign )getParamBool; - ParamStringBoolSign getParamBool2 = (ParamStringBoolSign )getParamBool; - ParamStringSign getParamInt1 = (ParamStringSign )getParamInt; - ParamStringIntSign getParamInt2 = (ParamStringIntSign )getParamInt; - ParamStringSign getParamEnumerate1 = (ParamStringSign )getParamEnumerate; - ParamStringIntSign getParamEnumerate2 = (ParamStringIntSign )getParamEnumerate; - ParamStringSign getParamDouble1 = (ParamStringSign )getParamDouble; - ParamStringDoubleSign getParamDouble2 = (ParamStringDoubleSign)getParamDouble; - ParamStringSign getParamPercentage1 = (ParamStringSign )getParamPercentage; - ParamStringDoubleSign getParamPercentage2 = (ParamStringDoubleSign)getParamPercentage; - def("getParamString" , getParamString1 , return_value_policy()); def("getParamString" , getParamString2 , return_value_policy()); def("getParamBool" , getParamBool1 , return_value_policy()); @@ -314,6 +342,30 @@ namespace Cfg { def("getParamPercentage", getParamPercentage1, return_value_policy()); def("getParamPercentage", getParamPercentage2, return_value_policy()); + enum_("ParameterWidgetFlags") + .value("UseSpinBox",ParameterWidget::UseSpinBox) + .value("IsFileName",ParameterWidget::IsFileName) + .value("IsPathName",ParameterWidget::IsPathName) + ; + + // { + // scope parameterWidgetScope + // ( class_("ParameterWidget", no_init) + // .def("getParameter", &ParameterWidget::getParameter, return_value_policy()) + // .def("hasFlags" , &ParameterWidget::hasFlags ) + // .def("unsetFlags" , &ParameterWidget::unsetFlags ) + // .add_property("flags", &ParameterWidget::getFlags, &ParameterWidget::setFlags) + // ); + + // implicitly_convertible(); + + // enum_("Flags") + // .value("UseSpinBox",ParameterWidget::UseSpinBox) + // .value("IsFileName",ParameterWidget::IsFileName) + // .value("IsPathName",ParameterWidget::IsPathName) + // ; + // } + } // End of Configuration BOOST_PYTHON_MODULE. diff --git a/vlsisapd/src/configuration/src/vlsisapd/configuration/Configuration.h b/vlsisapd/src/configuration/src/vlsisapd/configuration/Configuration.h index 226ff820..3668a46c 100644 --- a/vlsisapd/src/configuration/src/vlsisapd/configuration/Configuration.h +++ b/vlsisapd/src/configuration/src/vlsisapd/configuration/Configuration.h @@ -162,6 +162,8 @@ namespace Cfg { inline Parameter* getParamInt ( const std::string& id, int value=0 ) { + //std::cerr << "getParamInt() " << id << " value:" << value << std::endl; + Parameter* parameter = Configuration::get()->getParameter(id,Parameter::Int); if ( parameter == NULL ) { parameter = Configuration::get()->addParameter ( id, Parameter::Int, "0" ); @@ -221,6 +223,7 @@ namespace Cfg { { Parameter* parameter = Configuration::get()->getParameter(_id); if ( parameter != NULL ) parameter->setString ( _valid + , Configuration::getDefaultPriority() , (Parameter::AllRequirements | Parameter::FromString) & ~Parameter::TypeCheck ); diff --git a/vlsisapd/src/configuration/src/vlsisapd/configuration/Parameter.h b/vlsisapd/src/configuration/src/vlsisapd/configuration/Parameter.h index 7065a684..00af472d 100644 --- a/vlsisapd/src/configuration/src/vlsisapd/configuration/Parameter.h +++ b/vlsisapd/src/configuration/src/vlsisapd/configuration/Parameter.h @@ -109,8 +109,8 @@ namespace Cfg { inline void setFlags ( int mask ); inline void unsetFlags ( int mask ); bool setString ( const std::string& - , unsigned int flags =AllRequirements , Priority priority=UseDefault + , unsigned int flags =AllRequirements ); bool setBool ( bool , Priority priority=UseDefault ); bool setInt ( int , Priority priority=UseDefault );