* ./vlsisapd:
- New: In TabDescription, add an "id" field, to be used for filtering by the file drivers. - New: in LayoutDescription::writeToStream(), adds a filtering over the tabs id (same fonctionality as for the parameters). - New: PyConfiguration extension, build using boost::python. Not finished yet. - Bug: In LayoutDescription::buildWidget(), when the parameter associated to a widget is not found, to not try to adds it. Print a nice error message and do not core dump...
This commit is contained in:
parent
3801d65cdc
commit
61328d9c4c
|
@ -2,7 +2,9 @@
|
||||||
|
|
||||||
include ( ${QT_USE_FILE} )
|
include ( ${QT_USE_FILE} )
|
||||||
include_directories ( ${VLSISAPD_SOURCE_DIR}/src/configuration/src
|
include_directories ( ${VLSISAPD_SOURCE_DIR}/src/configuration/src
|
||||||
|
${VLSISAPD_SOURCE_DIR}/src/openChams/src
|
||||||
${Boost_INCLUDE_DIRS}
|
${Boost_INCLUDE_DIRS}
|
||||||
|
${PYTHON_INCLUDE_PATH}
|
||||||
${LIBXML2_INCLUDE_DIR}
|
${LIBXML2_INCLUDE_DIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -29,6 +31,7 @@
|
||||||
ConfigurationDialog.cpp
|
ConfigurationDialog.cpp
|
||||||
ConfEditorWidget.cpp
|
ConfEditorWidget.cpp
|
||||||
)
|
)
|
||||||
|
set ( pycpps PyConfiguration.cpp )
|
||||||
set ( editorcpp ConfEditorMain.cpp )
|
set ( editorcpp ConfEditorMain.cpp )
|
||||||
|
|
||||||
qt4_wrap_cpp ( mocCpps ${mocIncludes} )
|
qt4_wrap_cpp ( mocCpps ${mocIncludes} )
|
||||||
|
@ -41,6 +44,21 @@
|
||||||
${LIBXML2_LIBRARIES}
|
${LIBXML2_LIBRARIES}
|
||||||
${Boost_LIBRARIES}
|
${Boost_LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (Boost_FOUND)
|
||||||
|
add_library ( pyConfiguration MODULE ${pycpps})
|
||||||
|
set_target_properties ( pyConfiguration PROPERTIES
|
||||||
|
OUTPUT_NAME "Cfg"
|
||||||
|
PREFIX ""
|
||||||
|
)
|
||||||
|
target_link_libraries ( pyConfiguration configuration
|
||||||
|
${PYTHON_LIBRARIES}
|
||||||
|
${LIBXML2_LIBRARIES}
|
||||||
|
${Boost_LIBRARIES}
|
||||||
|
)
|
||||||
|
install ( TARGETS pyConfiguration DESTINATION ${PYTHON_SITE_PACKAGES} )
|
||||||
|
endif(Boost_FOUND)
|
||||||
|
|
||||||
add_executable ( vlsisapd-conf-editor ${editorcpp} )
|
add_executable ( vlsisapd-conf-editor ${editorcpp} )
|
||||||
target_link_libraries ( vlsisapd-conf-editor configuration ${Boost_LIBRARIES} )
|
target_link_libraries ( vlsisapd-conf-editor configuration ${Boost_LIBRARIES} )
|
||||||
|
|
||||||
|
|
|
@ -2,34 +2,33 @@
|
||||||
// -*- C++ -*-
|
// -*- C++ -*-
|
||||||
//
|
//
|
||||||
// This file is part of the VSLSI Stand-Alone Software.
|
// This file is part of the VSLSI Stand-Alone Software.
|
||||||
// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved
|
// Copyright (c) UPMC/LIP6 2008-2011, All Rights Reserved
|
||||||
//
|
//
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
//
|
//
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
// x-----------------------------------------------------------------x
|
// x-----------------------------------------------------------------x
|
||||||
// | |
|
|
||||||
// | C O R I O L I S |
|
// | C O R I O L I S |
|
||||||
// | C o n f i g u r a t i o n D a t a - B a s e |
|
// | C o n f i g u r a t i o n D a t a - B a s e |
|
||||||
// | |
|
// | |
|
||||||
// | Author : Jean-Paul CHAPUT |
|
// | Author : Jean-Paul CHAPUT |
|
||||||
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
|
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
||||||
// | =============================================================== |
|
// | =============================================================== |
|
||||||
// | C++ Module : "./ConfEditorMain.cpp" |
|
// | C++ Module : "./ConfEditorMain.cpp" |
|
||||||
// | *************************************************************** |
|
|
||||||
// | U p d a t e s |
|
|
||||||
// | |
|
|
||||||
// x-----------------------------------------------------------------x
|
// x-----------------------------------------------------------------x
|
||||||
|
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
#include <libxml/xmlreader.h>
|
||||||
|
#include <Python.h>
|
||||||
|
|
||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
namespace boptions = boost::program_options;
|
namespace boptions = boost::program_options;
|
||||||
|
|
||||||
#include <boost/filesystem/operations.hpp>
|
#include <boost/filesystem/operations.hpp>
|
||||||
namespace bfs = boost::filesystem;
|
namespace bfs = boost::filesystem;
|
||||||
|
|
||||||
#include <libxml/xmlreader.h>
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
#if (QT_VERSION >= QT_VERSION_CHECK(4,5,0)) and not defined (__APPLE__)
|
#if (QT_VERSION >= QT_VERSION_CHECK(4,5,0)) and not defined (__APPLE__)
|
||||||
# include <QGtkStyle>
|
# include <QGtkStyle>
|
||||||
|
@ -92,6 +91,23 @@ int main ( int argc, char* argv[] )
|
||||||
conf->readFromFile ( dotConfPath.string() );
|
conf->readFromFile ( dotConfPath.string() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cout << "misc.catchCore: " << conf->getParameter("misc.catchCore" )->asBool() << endl;
|
||||||
|
cout << "kite.eventsLimit: " << conf->getParameter("kite.eventsLimit")->asInt () << endl;
|
||||||
|
|
||||||
|
bfs::path pyDotConfPath ( "./.coriolis2.init.py" );
|
||||||
|
if ( bfs::exists(pyDotConfPath) ) {
|
||||||
|
cout << "Reading python dot configuration: <" << pyDotConfPath.string() << ">." << endl;
|
||||||
|
Py_Initialize ();
|
||||||
|
FILE* fd = fopen ( pyDotConfPath.string().c_str(), "r" );
|
||||||
|
if ( fd ) {
|
||||||
|
PyRun_SimpleFile ( fd, pyDotConfPath.string().c_str() );
|
||||||
|
fclose ( fd );
|
||||||
|
} else {
|
||||||
|
cout << "Cannot open Python configuration file: <" << pyDotConfPath.string() << ">." << endl;
|
||||||
|
}
|
||||||
|
Py_Finalize ();
|
||||||
|
}
|
||||||
|
|
||||||
ConfEditorWidget* editor = new ConfEditorWidget ();
|
ConfEditorWidget* editor = new ConfEditorWidget ();
|
||||||
editor->show ();
|
editor->show ();
|
||||||
//editor->getConfigurationWidget()->selectTab ( "Kite" );
|
//editor->getConfigurationWidget()->selectTab ( "Kite" );
|
||||||
|
|
|
@ -2,14 +2,13 @@
|
||||||
// -*- C++ -*-
|
// -*- C++ -*-
|
||||||
//
|
//
|
||||||
// This file is part of the VSLSI Stand-Alone Software.
|
// This file is part of the VSLSI Stand-Alone Software.
|
||||||
// Copyright (c) UPMC/LIP6 2010-2010, All Rights Reserved
|
// Copyright (c) UPMC/LIP6 2010-2011, All Rights Reserved
|
||||||
//
|
//
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
//
|
//
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
// x-----------------------------------------------------------------x
|
// +-----------------------------------------------------------------+
|
||||||
// | |
|
|
||||||
// | C O R I O L I S |
|
// | C O R I O L I S |
|
||||||
// | C o n f i g u r a t i o n D a t a - B a s e |
|
// | C o n f i g u r a t i o n D a t a - B a s e |
|
||||||
// | |
|
// | |
|
||||||
|
@ -17,10 +16,7 @@
|
||||||
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
||||||
// | =============================================================== |
|
// | =============================================================== |
|
||||||
// | C++ Module : "./ConfEditorWidget.cpp" |
|
// | C++ Module : "./ConfEditorWidget.cpp" |
|
||||||
// | *************************************************************** |
|
// +-----------------------------------------------------------------+
|
||||||
// | U p d a t e s |
|
|
||||||
// | |
|
|
||||||
// x-----------------------------------------------------------------x
|
|
||||||
|
|
||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
@ -91,7 +87,8 @@ namespace Cfg {
|
||||||
cout << "Saving configuration file: <" << dotConfigFile << ">."<< endl;
|
cout << "Saving configuration file: <" << dotConfigFile << ">."<< endl;
|
||||||
|
|
||||||
//Configuration::get()->writeToStream ( file, 0, ";misc;kite;;mauka;;" );
|
//Configuration::get()->writeToStream ( file, 0, ";misc;kite;;mauka;;" );
|
||||||
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 );
|
//Configuration::get()->writeToStream ( file, Configuration::DriveValues|Configuration::DriveLayout );
|
||||||
file.close ();
|
file.close ();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,25 +2,21 @@
|
||||||
// -*- C++ -*-
|
// -*- C++ -*-
|
||||||
//
|
//
|
||||||
// This file is part of the VSLSI Stand-Alone Software.
|
// This file is part of the VSLSI Stand-Alone Software.
|
||||||
// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved
|
// Copyright (c) UPMC/LIP6 2008-2011, All Rights Reserved
|
||||||
//
|
//
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
//
|
//
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
// x-----------------------------------------------------------------x
|
// +-----------------------------------------------------------------+
|
||||||
// | |
|
|
||||||
// | C O R I O L I S |
|
// | C O R I O L I S |
|
||||||
// | C o n f i g u r a t i o n D a t a - B a s e |
|
// | C o n f i g u r a t i o n D a t a - B a s e |
|
||||||
// | |
|
// | |
|
||||||
// | Author : Jean-Paul CHAPUT |
|
// | Author : Jean-Paul CHAPUT |
|
||||||
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
|
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
||||||
// | =============================================================== |
|
// | =============================================================== |
|
||||||
// | C++ Module : "./Configuration.cpp" |
|
// | C++ Module : "./Configuration.cpp" |
|
||||||
// | *************************************************************** |
|
// +-----------------------------------------------------------------+
|
||||||
// | U p d a t e s |
|
|
||||||
// | |
|
|
||||||
// x-----------------------------------------------------------------x
|
|
||||||
|
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
@ -41,24 +37,6 @@ namespace {
|
||||||
using namespace Cfg;
|
using namespace Cfg;
|
||||||
|
|
||||||
|
|
||||||
void tokenize ( set<string>& tokens, const string& line )
|
|
||||||
{
|
|
||||||
static std::string separators = " ;";
|
|
||||||
size_t iBegin = 0;
|
|
||||||
size_t iEnd = 0;
|
|
||||||
|
|
||||||
for ( ; iEnd < line.size() ; ++iEnd ) {
|
|
||||||
if ( separators.find(line[iEnd]) != std::string::npos ) {
|
|
||||||
if ( iBegin < iEnd )
|
|
||||||
tokens.insert ( line.substr(iBegin,iEnd-iBegin) );
|
|
||||||
iBegin = iEnd+1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( iBegin < iEnd )
|
|
||||||
tokens.insert ( line.substr(iBegin,iEnd-iBegin) );
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
class XmlParser {
|
class XmlParser {
|
||||||
public:
|
public:
|
||||||
XmlParser ( Configuration*, const string& fileName );
|
XmlParser ( Configuration*, const string& fileName );
|
||||||
|
@ -99,6 +77,8 @@ namespace {
|
||||||
{
|
{
|
||||||
LIBXML_TEST_VERSION;
|
LIBXML_TEST_VERSION;
|
||||||
|
|
||||||
|
Configuration::pushDefaultPriority ( Parameter::ConfigurationFile );
|
||||||
|
|
||||||
_reader = xmlReaderForFile ( _fileName.c_str(), NULL, 0 );
|
_reader = xmlReaderForFile ( _fileName.c_str(), NULL, 0 );
|
||||||
if ( _reader != NULL ) {
|
if ( _reader != NULL ) {
|
||||||
_status = xmlTextReaderRead ( _reader );
|
_status = xmlTextReaderRead ( _reader );
|
||||||
|
@ -116,6 +96,8 @@ namespace {
|
||||||
// xmlCleanupParser (); // CF libxml2 documentation if libxml2 parser is use by the application any other time : DO NOT CALL xmlCleanupParser (at least on mac osx)
|
// xmlCleanupParser (); // CF libxml2 documentation if libxml2 parser is use by the application any other time : DO NOT CALL xmlCleanupParser (at least on mac osx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Configuration::popDefaultPriority ();
|
||||||
|
|
||||||
return (_status == 0);
|
return (_status == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,7 +144,6 @@ namespace {
|
||||||
_parameter = _configuration->addParameter ( attrId
|
_parameter = _configuration->addParameter ( attrId
|
||||||
, type
|
, type
|
||||||
, _getAttributeValue("value")
|
, _getAttributeValue("value")
|
||||||
, Parameter::ConfigurationFile
|
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
_parameter->setString ( _getAttributeValue("value")
|
_parameter->setString ( _getAttributeValue("value")
|
||||||
|
@ -288,8 +269,9 @@ namespace {
|
||||||
void XmlParser::_tabNode ()
|
void XmlParser::_tabNode ()
|
||||||
{
|
{
|
||||||
string attrName = _getAttributeValue("name");
|
string attrName = _getAttributeValue("name");
|
||||||
|
string attrId = _getAttributeValue("id");
|
||||||
|
|
||||||
_configuration->getLayout().addTab ( attrName );
|
_configuration->getLayout().addTab ( attrName, attrId );
|
||||||
|
|
||||||
_status = xmlTextReaderRead ( _reader );
|
_status = xmlTextReaderRead ( _reader );
|
||||||
while ( _status == 1 ) {
|
while ( _status == 1 ) {
|
||||||
|
@ -378,6 +360,24 @@ namespace Cfg {
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
|
||||||
|
|
||||||
|
void Configuration::_tokenize ( set<string>& tokens, const string& line )
|
||||||
|
{
|
||||||
|
static std::string separators = " ;";
|
||||||
|
size_t iBegin = 0;
|
||||||
|
size_t iEnd = 0;
|
||||||
|
|
||||||
|
for ( ; iEnd < line.size() ; ++iEnd ) {
|
||||||
|
if ( separators.find(line[iEnd]) != std::string::npos ) {
|
||||||
|
if ( iBegin < iEnd )
|
||||||
|
tokens.insert ( line.substr(iBegin,iEnd-iBegin) );
|
||||||
|
iBegin = iEnd+1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( iBegin < iEnd )
|
||||||
|
tokens.insert ( line.substr(iBegin,iEnd-iBegin) );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Configuration* Configuration::_singleton = NULL;
|
Configuration* Configuration::_singleton = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
@ -388,6 +388,18 @@ namespace Cfg {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Parameter::Priority Configuration::pushDefaultPriority ( Parameter::Priority priority )
|
||||||
|
{ return Parameter::pushDefaultPriority(priority); }
|
||||||
|
|
||||||
|
|
||||||
|
Parameter::Priority Configuration::popDefaultPriority ()
|
||||||
|
{ return Parameter::popDefaultPriority(); }
|
||||||
|
|
||||||
|
|
||||||
|
Parameter::Priority Configuration::getDefaultPriority ()
|
||||||
|
{ return Parameter::getDefaultPriority(); }
|
||||||
|
|
||||||
|
|
||||||
Configuration::Configuration ()
|
Configuration::Configuration ()
|
||||||
: _parameters()
|
: _parameters()
|
||||||
, _layout (this)
|
, _layout (this)
|
||||||
|
@ -429,7 +441,7 @@ namespace Cfg {
|
||||||
Parameter* Configuration::addParameter ( const string& id
|
Parameter* Configuration::addParameter ( const string& id
|
||||||
, Parameter::Type type
|
, Parameter::Type type
|
||||||
, const string& value
|
, const string& value
|
||||||
, int priority )
|
, Parameter::Priority priority )
|
||||||
{
|
{
|
||||||
Parameter* p = getParameter ( id );
|
Parameter* p = getParameter ( id );
|
||||||
if ( p != NULL ) {
|
if ( p != NULL ) {
|
||||||
|
@ -520,7 +532,7 @@ namespace Cfg {
|
||||||
void Configuration::writeToStream ( ostream& out, unsigned int flags, const string& tabs ) const
|
void Configuration::writeToStream ( ostream& out, unsigned int flags, const string& tabs ) const
|
||||||
{
|
{
|
||||||
set<string> tabset;
|
set<string> tabset;
|
||||||
tokenize ( tabset, tabs );
|
_tokenize ( tabset, tabs );
|
||||||
|
|
||||||
out << "<configuration>" << endl;
|
out << "<configuration>" << endl;
|
||||||
|
|
||||||
|
@ -585,6 +597,16 @@ namespace Cfg {
|
||||||
const vector<string>& slaves = p->getSlaves();
|
const vector<string>& slaves = p->getSlaves();
|
||||||
if ( slaves.empty() ) continue;
|
if ( slaves.empty() ) continue;
|
||||||
|
|
||||||
|
if ( not tabset.empty() ) {
|
||||||
|
set<string>::iterator itab = tabset.begin();
|
||||||
|
for ( ; itab != tabset.end() ; ++itab ) {
|
||||||
|
if ( p->getId().compare(0,(*itab).size(),*itab) == 0 ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( itab == tabset.end() ) continue;
|
||||||
|
}
|
||||||
|
|
||||||
out << " <group>" << endl;
|
out << " <group>" << endl;
|
||||||
out << " <master id=\"" << p->getId() << "\"/>" << endl;
|
out << " <master id=\"" << p->getId() << "\"/>" << endl;
|
||||||
|
|
||||||
|
@ -595,7 +617,7 @@ namespace Cfg {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( flags & DriveLayout ) _layout.writeToStream ( out );
|
if ( flags & DriveLayout ) _layout.writeToStream ( out, tabs );
|
||||||
|
|
||||||
out << "</configuration>" << endl;
|
out << "</configuration>" << endl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,13 @@
|
||||||
// -*- C++ -*-
|
// -*- C++ -*-
|
||||||
//
|
//
|
||||||
// This file is part of the VSLSI Stand-Alone Software.
|
// This file is part of the VSLSI Stand-Alone Software.
|
||||||
// Copyright (c) UPMC/LIP6 2010-2010, All Rights Reserved
|
// Copyright (c) UPMC/LIP6 2010-2011, All Rights Reserved
|
||||||
//
|
//
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
//
|
//
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
// x-----------------------------------------------------------------x
|
// +-----------------------------------------------------------------+
|
||||||
// | |
|
|
||||||
// | C O R I O L I S |
|
// | C O R I O L I S |
|
||||||
// | C o n f i g u r a t i o n D a t a - B a s e |
|
// | C o n f i g u r a t i o n D a t a - B a s e |
|
||||||
// | |
|
// | |
|
||||||
|
@ -17,10 +16,7 @@
|
||||||
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
||||||
// | =============================================================== |
|
// | =============================================================== |
|
||||||
// | C++ Module : "./LayoutDescription.cpp" |
|
// | C++ Module : "./LayoutDescription.cpp" |
|
||||||
// | *************************************************************** |
|
// +-----------------------------------------------------------------+
|
||||||
// | U p d a t e s |
|
|
||||||
// | |
|
|
||||||
// x-----------------------------------------------------------------x
|
|
||||||
|
|
||||||
|
|
||||||
#include "vlsisapd/configuration/LayoutDescription.h"
|
#include "vlsisapd/configuration/LayoutDescription.h"
|
||||||
|
@ -35,6 +31,7 @@ namespace Cfg {
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::vector;
|
using std::vector;
|
||||||
|
using std::set;
|
||||||
using std::map;
|
using std::map;
|
||||||
using std::make_pair;
|
using std::make_pair;
|
||||||
using std::ostream;
|
using std::ostream;
|
||||||
|
@ -62,13 +59,13 @@ namespace Cfg {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
TabDescription* LayoutDescription::getTab ( const string& tabName )
|
TabDescription* LayoutDescription::getTab ( const string& tabName, const string& id )
|
||||||
{
|
{
|
||||||
for ( size_t itab=0 ; itab<_tabs.size() ; ++itab ) {
|
for ( size_t itab=0 ; itab<_tabs.size() ; ++itab ) {
|
||||||
if ( _tabs[itab]->getName() == tabName ) return _tabs[itab];
|
if ( _tabs[itab]->getName() == tabName ) return _tabs[itab];
|
||||||
}
|
}
|
||||||
|
|
||||||
addTab ( new TabDescription(this,tabName) );
|
addTab ( new TabDescription(this,tabName,id) );
|
||||||
return getBackTab();
|
return getBackTab();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,12 +128,17 @@ namespace Cfg {
|
||||||
break;
|
break;
|
||||||
case WidgetDescription::Parameter:
|
case WidgetDescription::Parameter:
|
||||||
Parameter* parameter = _configuration->getParameter ( widgets[iwidget]->getId() );
|
Parameter* parameter = _configuration->getParameter ( widgets[iwidget]->getId() );
|
||||||
|
if ( parameter ) {
|
||||||
cw->addParameter ( _tabs[itab]->getName()
|
cw->addParameter ( _tabs[itab]->getName()
|
||||||
, parameter
|
, parameter
|
||||||
, widgets[iwidget]->getLabel()
|
, widgets[iwidget]->getLabel()
|
||||||
, widgets[iwidget]->getColumn()
|
, widgets[iwidget]->getColumn()
|
||||||
, widgets[iwidget]->getSpan()
|
, widgets[iwidget]->getSpan()
|
||||||
, widgets[iwidget]->getFlags() );
|
, widgets[iwidget]->getFlags() );
|
||||||
|
} else {
|
||||||
|
cerr << "[ERROR] LayoutDescription::buildWidget(): reference to non-existent parameter id=\""
|
||||||
|
<< widgets[iwidget]->getId() << "\"." << endl;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -148,12 +150,27 @@ namespace Cfg {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LayoutDescription::writeToStream ( ostream& out ) const
|
void LayoutDescription::writeToStream ( ostream& out, const string& tabs ) const
|
||||||
{
|
{
|
||||||
|
set<string> tabset;
|
||||||
|
Configuration::_tokenize ( tabset, tabs );
|
||||||
|
|
||||||
out << " <layout>" << endl;
|
out << " <layout>" << endl;
|
||||||
|
|
||||||
for ( size_t itab=0 ; itab<_tabs.size() ; ++itab ) {
|
for ( size_t itab=0 ; itab<_tabs.size() ; ++itab ) {
|
||||||
out << " <tab name=\"" << _tabs[itab]->getName() << "\">" << endl;
|
if ( not tabset.empty() ) {
|
||||||
|
set<string>::iterator isavetab = tabset.begin();
|
||||||
|
for ( ; isavetab != tabset.end() ; ++isavetab ) {
|
||||||
|
if ( _tabs[itab]->getId().compare(0,(*isavetab).size(),*isavetab) == 0 ) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ( isavetab == tabset.end() ) continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
out << " <tab name=\"" << _tabs[itab]->getName()
|
||||||
|
<< "\" id=\"" << _tabs[itab]->getId()
|
||||||
|
<< "\">" << endl;
|
||||||
|
|
||||||
const vector<WidgetDescription*>& widgets = _tabs[itab]->getWidgets();
|
const vector<WidgetDescription*>& widgets = _tabs[itab]->getWidgets();
|
||||||
for ( size_t iwidget=0 ; iwidget<widgets.size() ; ++iwidget ) {
|
for ( size_t iwidget=0 ; iwidget<widgets.size() ; ++iwidget ) {
|
||||||
|
|
|
@ -2,25 +2,21 @@
|
||||||
// -*- C++ -*-
|
// -*- C++ -*-
|
||||||
//
|
//
|
||||||
// This file is part of the VSLSI Stand-Alone Software.
|
// This file is part of the VSLSI Stand-Alone Software.
|
||||||
// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved
|
// Copyright (c) UPMC/LIP6 2008-2011, All Rights Reserved
|
||||||
//
|
//
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
//
|
//
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
// x-----------------------------------------------------------------x
|
// +-----------------------------------------------------------------+
|
||||||
// | |
|
|
||||||
// | C O R I O L I S |
|
// | C O R I O L I S |
|
||||||
// | C o n f i g u r a t i o n D a t a - B a s e |
|
// | C o n f i g u r a t i o n D a t a - B a s e |
|
||||||
// | |
|
// | |
|
||||||
// | Author : Jean-Paul CHAPUT |
|
// | Author : Jean-Paul CHAPUT |
|
||||||
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
|
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
||||||
// | =============================================================== |
|
// | =============================================================== |
|
||||||
// | C++ Header : "./Parameter.cpp" |
|
// | C++ Header : "./Parameter.cpp" |
|
||||||
// | *************************************************************** |
|
// +-----------------------------------------------------------------+
|
||||||
// | U p d a t e s |
|
|
||||||
// | |
|
|
||||||
// x-----------------------------------------------------------------x
|
|
||||||
|
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
@ -39,6 +35,31 @@ namespace Cfg {
|
||||||
using std::ostringstream;
|
using std::ostringstream;
|
||||||
using std::boolalpha;
|
using std::boolalpha;
|
||||||
using std::hex;
|
using std::hex;
|
||||||
|
using std::vector;
|
||||||
|
|
||||||
|
|
||||||
|
vector<Parameter::Priority> Parameter::_defaultPriorities (1,Parameter::ApplicationBuiltin);
|
||||||
|
|
||||||
|
|
||||||
|
Parameter::Priority Parameter::pushDefaultPriority ( Parameter::Priority priority )
|
||||||
|
{
|
||||||
|
Priority previous = _defaultPriorities.back ();
|
||||||
|
_defaultPriorities.push_back ( priority );
|
||||||
|
return previous;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Parameter::Priority Parameter::popDefaultPriority ()
|
||||||
|
{
|
||||||
|
Priority previous = _defaultPriorities.back ();
|
||||||
|
if ( _defaultPriorities.size() > 1 )
|
||||||
|
_defaultPriorities.pop_back ();
|
||||||
|
return previous;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Parameter::Priority Parameter::getDefaultPriority ()
|
||||||
|
{ return _defaultPriorities.back(); }
|
||||||
|
|
||||||
|
|
||||||
string Parameter::typeToString ( Parameter::Type type )
|
string Parameter::typeToString ( Parameter::Type type )
|
||||||
|
@ -59,7 +80,7 @@ namespace Cfg {
|
||||||
Parameter::Parameter ( const std::string& id
|
Parameter::Parameter ( const std::string& id
|
||||||
, Type type
|
, Type type
|
||||||
, const std::string& value
|
, const std::string& value
|
||||||
, int priority
|
, Priority priority
|
||||||
)
|
)
|
||||||
: _id (id)
|
: _id (id)
|
||||||
, _type (type)
|
, _type (type)
|
||||||
|
@ -77,6 +98,7 @@ namespace Cfg {
|
||||||
if ( type == Percentage ) {
|
if ( type == Percentage ) {
|
||||||
setPercentage ( asDouble() );
|
setPercentage ( asDouble() );
|
||||||
}
|
}
|
||||||
|
if ( priority == UseDefault ) _priority = getDefaultPriority();
|
||||||
|
|
||||||
//cerr << "New " << typeToString(_type) << " parameter " << _id << " value:" << _value << endl;
|
//cerr << "New " << typeToString(_type) << " parameter " << _id << " value:" << _value << endl;
|
||||||
}
|
}
|
||||||
|
@ -140,10 +162,9 @@ namespace Cfg {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Parameter::setString ( const std::string& s, unsigned int flags, int priority )
|
bool Parameter::setString ( const std::string& s, unsigned int flags, Priority priority )
|
||||||
{
|
{
|
||||||
if ( priority < _priority ) return false;
|
if ( not _updatePriority(priority) ) return false;
|
||||||
_priority = priority;
|
|
||||||
|
|
||||||
if ( (flags & TypeCheck) and (_type != String) )
|
if ( (flags & TypeCheck) and (_type != String) )
|
||||||
cerr << "[ERROR] Parameter::setString(): Setting " << Parameter::typeToString(_type)
|
cerr << "[ERROR] Parameter::setString(): Setting " << Parameter::typeToString(_type)
|
||||||
|
@ -154,10 +175,9 @@ namespace Cfg {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Parameter::setBool ( bool b, int priority )
|
bool Parameter::setBool ( bool b, Priority priority )
|
||||||
{
|
{
|
||||||
if ( priority < _priority ) return false;
|
if ( not _updatePriority(priority) ) return false;
|
||||||
_priority = priority;
|
|
||||||
|
|
||||||
if ( _type != Bool )
|
if ( _type != Bool )
|
||||||
cerr << "[ERROR] Parameter::setBool(): Setting " << Parameter::typeToString(_type)
|
cerr << "[ERROR] Parameter::setBool(): Setting " << Parameter::typeToString(_type)
|
||||||
|
@ -168,10 +188,9 @@ namespace Cfg {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Parameter::setInt ( int i, int priority )
|
bool Parameter::setInt ( int i, Priority priority )
|
||||||
{
|
{
|
||||||
if ( priority < _priority ) return false;
|
if ( not _updatePriority(priority) ) return false;
|
||||||
_priority = priority;
|
|
||||||
|
|
||||||
if ( (_type != Int) and (_type != Enumerate) )
|
if ( (_type != Int) and (_type != Enumerate) )
|
||||||
cerr << "[ERROR] Parameter::setInt(): Setting " << Parameter::typeToString(_type)
|
cerr << "[ERROR] Parameter::setInt(): Setting " << Parameter::typeToString(_type)
|
||||||
|
@ -182,10 +201,9 @@ namespace Cfg {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Parameter::setDouble ( double d, int priority )
|
bool Parameter::setDouble ( double d, Priority priority )
|
||||||
{
|
{
|
||||||
if ( priority < _priority ) return false;
|
if ( not _updatePriority(priority) ) return false;
|
||||||
_priority = priority;
|
|
||||||
|
|
||||||
if ( (_type != Double) and (_type != Percentage) )
|
if ( (_type != Double) and (_type != Percentage) )
|
||||||
cerr << "[ERROR] Parameter::setDouble(): Setting " << Parameter::typeToString(_type)
|
cerr << "[ERROR] Parameter::setDouble(): Setting " << Parameter::typeToString(_type)
|
||||||
|
@ -196,8 +214,10 @@ namespace Cfg {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Parameter::setPercentage ( double d, int priority )
|
bool Parameter::setPercentage ( double d, Priority priority )
|
||||||
{
|
{
|
||||||
|
if ( not _updatePriority(priority) ) return false;
|
||||||
|
|
||||||
if ( (_type != Double) and (_type != Percentage) )
|
if ( (_type != Double) and (_type != Percentage) )
|
||||||
cerr << "[ERROR] Parameter::setPercentage(): Setting " << Parameter::typeToString(_type)
|
cerr << "[ERROR] Parameter::setPercentage(): Setting " << Parameter::typeToString(_type)
|
||||||
<< " parameter <" << _id
|
<< " parameter <" << _id
|
||||||
|
@ -207,6 +227,32 @@ namespace Cfg {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Parameter::setMin ( int min, Parameter::Priority priority )
|
||||||
|
{ if (_updatePriority(priority)) { _minInt = min; setFlags(HasMin); } }
|
||||||
|
|
||||||
|
|
||||||
|
void Parameter::setMax ( int max, Parameter::Priority priority )
|
||||||
|
{ if (_updatePriority(priority)) { _maxInt = max; setFlags(HasMax); } }
|
||||||
|
|
||||||
|
|
||||||
|
void Parameter::setMin ( double min, Parameter::Priority priority )
|
||||||
|
{ if (_updatePriority(priority)) {
|
||||||
|
_minDouble = min;
|
||||||
|
setFlags ( HasMin );
|
||||||
|
if (_type==Percentage) _minDouble/=100.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void Parameter::setMax ( double max, Parameter::Priority priority )
|
||||||
|
{ if (_updatePriority(priority)) {
|
||||||
|
_maxDouble = max;
|
||||||
|
setFlags ( HasMax );
|
||||||
|
if (_type==Percentage) _maxDouble/=100.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Parameter::_doChange ( unsigned int flags, const string& s, bool b, int i, double d )
|
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;
|
||||||
|
|
|
@ -0,0 +1,321 @@
|
||||||
|
|
||||||
|
// -*- C++ -*-
|
||||||
|
//
|
||||||
|
// This file is part of the VSLSI Stand-Alone Software.
|
||||||
|
// Copyright (c) UPMC/LIP6 2008-2011, All Rights Reserved
|
||||||
|
//
|
||||||
|
// ===================================================================
|
||||||
|
//
|
||||||
|
// $Id$
|
||||||
|
//
|
||||||
|
// +-----------------------------------------------------------------+
|
||||||
|
// | C O R I O L I S |
|
||||||
|
// | C o n f i g u r a t i o n D a t a - B a s e |
|
||||||
|
// | |
|
||||||
|
// | Author : Jean-Paul CHAPUT |
|
||||||
|
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
||||||
|
// | =============================================================== |
|
||||||
|
// | C++ Module : "./PyConfiguration.cpp" |
|
||||||
|
// +-----------------------------------------------------------------+
|
||||||
|
|
||||||
|
|
||||||
|
#include <boost/python.hpp>
|
||||||
|
#include <boost/python/suite/indexing/vector_indexing_suite.hpp>
|
||||||
|
using namespace boost::python;
|
||||||
|
|
||||||
|
#include "vlsisapd/openChams/PySTLMapWrapper.h"
|
||||||
|
using OpenChams::map_item;
|
||||||
|
|
||||||
|
#include "vlsisapd/configuration/Configuration.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
|
||||||
|
using namespace Cfg;
|
||||||
|
|
||||||
|
|
||||||
|
template<typename EnumType>
|
||||||
|
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); }
|
||||||
|
|
||||||
|
// STL map wrapper for boost::python.
|
||||||
|
template<typename Map>
|
||||||
|
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& );
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
inline void KeyError () { PyErr_SetString(PyExc_KeyError, "Key not found"); }
|
||||||
|
|
||||||
|
|
||||||
|
template<typename Map>
|
||||||
|
typename MapWrapper<Map>::Value& MapWrapper<Map>::get ( Map& m, const typename MapWrapper<Map>::Key& k )
|
||||||
|
{
|
||||||
|
static Value notFound;
|
||||||
|
if( m.find(k) != m.end() ) return m[k];
|
||||||
|
KeyError ();
|
||||||
|
return notFound;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Map>
|
||||||
|
void MapWrapper<Map>::set ( Map& m, const MapWrapper<Map>::Key& k, const typename MapWrapper<Map>::Value& v )
|
||||||
|
{ m[k] = v; }
|
||||||
|
|
||||||
|
template<typename Map>
|
||||||
|
void MapWrapper<Map>::del ( Map& m, const typename MapWrapper<Map>::Key& k)
|
||||||
|
{
|
||||||
|
if( m.find(k) != m.end() ) m.erase(k);
|
||||||
|
else KeyError ();
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Map>
|
||||||
|
bool MapWrapper<Map>::in ( Map& m, const typename MapWrapper<Map>::Key& k )
|
||||||
|
{ return m.find(k) != m.end(); }
|
||||||
|
|
||||||
|
template<typename Map>
|
||||||
|
list MapWrapper<Map>::keys ( Map& m )
|
||||||
|
{
|
||||||
|
list l;
|
||||||
|
for(typename Map::iterator it = m.begin() ; it != m.end() ; ++it )
|
||||||
|
l.append ( it->first );
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Map>
|
||||||
|
list MapWrapper<Map>::values ( Map& m)
|
||||||
|
{
|
||||||
|
list l;
|
||||||
|
for( typename Map::iterator it=m.begin(); it != m.end() ; ++it )
|
||||||
|
l.append ( it->second );
|
||||||
|
return l;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename Map>
|
||||||
|
list MapWrapper<Map>::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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // End of anonymous namespace.
|
||||||
|
|
||||||
|
|
||||||
|
namespace Cfg {
|
||||||
|
|
||||||
|
|
||||||
|
BOOST_PYTHON_MODULE(Cfg) {
|
||||||
|
|
||||||
|
typedef void (Parameter::* VoidIntPrioritySign )(int ,Parameter::Priority) ;
|
||||||
|
typedef void (Parameter::* VoidDoublePrioritySign )(double,Parameter::Priority) ;
|
||||||
|
typedef void (Parameter::* VoidIntSign )(int );
|
||||||
|
typedef void (Parameter::* VoidDoubleSign )(double);
|
||||||
|
typedef bool (Parameter::* BoolIntConstSign )(int ) const;
|
||||||
|
typedef bool (Parameter::* BoolDoubleConstSign )(double) const;
|
||||||
|
typedef bool (Parameter::* BoolBoolSign )(bool );
|
||||||
|
typedef bool (Parameter::* BoolIntSign )(int );
|
||||||
|
typedef bool (Parameter::* BoolDoubleSign )(double);
|
||||||
|
typedef bool (Parameter::* BoolStringSign )(std::string);
|
||||||
|
typedef bool (Parameter::* BoolStringFlagsSign )(std::string,unsigned int);
|
||||||
|
|
||||||
|
// 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<Parameter::Type ,int>();
|
||||||
|
implicitly_convertible<Parameter::Flags ,int>();
|
||||||
|
implicitly_convertible<Parameter::Priority,int>();
|
||||||
|
|
||||||
|
//to_python_converter<const Parameter::Type ,EnumToInt<const Parameter::Type> >();
|
||||||
|
|
||||||
|
{
|
||||||
|
scope paramScope
|
||||||
|
( class_<Parameter>("Parameter", init<const std::string&, Parameter::Type, const std::string&
|
||||||
|
,optional<Parameter::Priority> >())
|
||||||
|
.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<reference_existing_object>())
|
||||||
|
.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<reference_existing_object>())
|
||||||
|
.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)
|
||||||
|
|
||||||
|
//.add_property("flags", &Parameter::getFlags, &Parameter::setFlags)
|
||||||
|
.add_property("type" , &Parameter::getType)
|
||||||
|
);
|
||||||
|
|
||||||
|
enum_<Parameter::Type>("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)
|
||||||
|
;
|
||||||
|
|
||||||
|
enum_<Parameter::Priority>("Priority")
|
||||||
|
.value("UseDefault" ,Parameter::UseDefault)
|
||||||
|
.value("ApplicationBuiltin",Parameter::ApplicationBuiltin)
|
||||||
|
.value("ConfigurationFile" ,Parameter::ConfigurationFile)
|
||||||
|
.value("CommandLine" ,Parameter::CommandLine)
|
||||||
|
.value("Interactive" ,Parameter::Interactive)
|
||||||
|
;
|
||||||
|
|
||||||
|
enum_<Parameter::Flags>("Flags")
|
||||||
|
.value("HasMin" , Parameter::HasMin)
|
||||||
|
.value("HasMax" , Parameter::HasMax)
|
||||||
|
.value("IsFile" , Parameter::IsFile)
|
||||||
|
.value("IsPath" , Parameter::IsPath)
|
||||||
|
.value("NeedRestart" , Parameter::NeedRestart)
|
||||||
|
.value("MustExist" , Parameter::MustExist)
|
||||||
|
.value("TypeCheck" , Parameter::TypeCheck)
|
||||||
|
.value("FromString" , Parameter::FromString)
|
||||||
|
.value("AllRequirements", Parameter::AllRequirements)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef std::map <const std::string,Parameter*> ParametersMap;
|
||||||
|
typedef std::pair<const std::string,Parameter*> ParametersPair;
|
||||||
|
|
||||||
|
class_<ParametersPair>("ParametersPair")
|
||||||
|
.def_readonly ("key" , &ParametersPair::first )
|
||||||
|
.def_readwrite("value", &ParametersPair::second)
|
||||||
|
;
|
||||||
|
class_<ParametersMap>("ParametersMap")
|
||||||
|
.def("__len__" , &ParametersMap::size)
|
||||||
|
.def("clear" , &ParametersMap::clear)
|
||||||
|
.def("__getitem__" , &MapWrapper<ParametersMap>::get, return_value_policy<reference_existing_object>())
|
||||||
|
.def("__setitem__" , &MapWrapper<ParametersMap>::set, return_value_policy<reference_existing_object>())
|
||||||
|
.def("__delitem__" , &MapWrapper<ParametersMap>::del)
|
||||||
|
.def("__contains__" , &MapWrapper<ParametersMap>::in )
|
||||||
|
.def("has_key" , &MapWrapper<ParametersMap>::in )
|
||||||
|
.def("keys" , &MapWrapper<ParametersMap>::keys )
|
||||||
|
.def("values" , &MapWrapper<ParametersMap>::values )
|
||||||
|
.def("items" , &MapWrapper<ParametersMap>::items )
|
||||||
|
;
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
{
|
||||||
|
scope confScope
|
||||||
|
( class_<Configuration>("Configuration", no_init)
|
||||||
|
.def("get" , &Configuration::get , return_value_policy<reference_existing_object>())
|
||||||
|
.def("getParameter" , CfgGetParameter1 , return_value_policy<reference_existing_object>())
|
||||||
|
.def("getParameter" , CfgGetParameter2 , return_value_policy<reference_existing_object>())
|
||||||
|
.def("pushDefaultPriority", &Configuration::pushDefaultPriority)
|
||||||
|
.def("popDefaultPriority" , &Configuration::popDefaultPriority )
|
||||||
|
.def("getDefaultPriority" , &Configuration::getDefaultPriority )
|
||||||
|
.def("getParameters" , &Configuration::getParameters , return_value_policy<reference_existing_object>())
|
||||||
|
.staticmethod("get")
|
||||||
|
.staticmethod("pushDefaultPriority")
|
||||||
|
.staticmethod("popDefaultPriority")
|
||||||
|
.staticmethod("getDefaultPriority")
|
||||||
|
.add_property("flags", &Configuration::getFlags, &Configuration::setFlags)
|
||||||
|
);
|
||||||
|
|
||||||
|
implicitly_convertible<Configuration::Flags,int>();
|
||||||
|
|
||||||
|
enum_<Configuration::Flags>("Flags")
|
||||||
|
.value("DriveValues",Configuration::DriveValues)
|
||||||
|
.value("DriveLayout",Configuration::DriveLayout)
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 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<reference_existing_object>());
|
||||||
|
def("getParamString" , getParamString2 , return_value_policy<reference_existing_object>());
|
||||||
|
def("getParamBool" , getParamBool1 , return_value_policy<reference_existing_object>());
|
||||||
|
def("getParamBool" , getParamBool2 , return_value_policy<reference_existing_object>());
|
||||||
|
def("getParamInt" , getParamInt1 , return_value_policy<reference_existing_object>());
|
||||||
|
def("getParamInt" , getParamInt2 , return_value_policy<reference_existing_object>());
|
||||||
|
def("getParamEnumerate" , getParamEnumerate1 , return_value_policy<reference_existing_object>());
|
||||||
|
def("getParamEnumerate" , getParamEnumerate2 , return_value_policy<reference_existing_object>());
|
||||||
|
def("getParamDouble" , getParamDouble1 , return_value_policy<reference_existing_object>());
|
||||||
|
def("getParamDouble" , getParamDouble2 , return_value_policy<reference_existing_object>());
|
||||||
|
def("getParamPercentage", getParamPercentage1, return_value_policy<reference_existing_object>());
|
||||||
|
def("getParamPercentage", getParamPercentage2, return_value_policy<reference_existing_object>());
|
||||||
|
|
||||||
|
} // End of Configuration BOOST_PYTHON_MODULE.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
} // End of Cfg namespace.
|
|
@ -2,24 +2,20 @@
|
||||||
// -*- C++ -*-
|
// -*- C++ -*-
|
||||||
//
|
//
|
||||||
// This file is part of the VSLSI Stand-Alone Software.
|
// This file is part of the VSLSI Stand-Alone Software.
|
||||||
// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved
|
// Copyright (c) UPMC/LIP6 2008-2011, All Rights Reserved
|
||||||
//
|
//
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
//
|
//
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
// x-----------------------------------------------------------------x
|
// x-----------------------------------------------------------------x
|
||||||
// | |
|
|
||||||
// | C O R I O L I S |
|
// | C O R I O L I S |
|
||||||
// | C o n f i g u r a t i o n D a t a - B a s e |
|
// | C o n f i g u r a t i o n D a t a - B a s e |
|
||||||
// | |
|
// | |
|
||||||
// | Author : Jean-Paul CHAPUT |
|
// | Author : Jean-Paul CHAPUT |
|
||||||
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
|
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
||||||
// | =============================================================== |
|
// | =============================================================== |
|
||||||
// | C++ Header : "./Configuration.h" |
|
// | C++ Header : "./Configuration.h" |
|
||||||
// | *************************************************************** |
|
|
||||||
// | U p d a t e s |
|
|
||||||
// | |
|
|
||||||
// x-----------------------------------------------------------------x
|
// x-----------------------------------------------------------------x
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,6 +54,10 @@ namespace Cfg {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static Configuration* get ();
|
static Configuration* get ();
|
||||||
|
static Parameter::Priority pushDefaultPriority ( Parameter::Priority );
|
||||||
|
static Parameter::Priority popDefaultPriority ();
|
||||||
|
static Parameter::Priority getDefaultPriority ();
|
||||||
|
static void _tokenize ( std::set<std::string>& tokens, const std::string& line );
|
||||||
public:
|
public:
|
||||||
// Methods.
|
// Methods.
|
||||||
ConfigurationWidget* buildWidget ( unsigned int flags );
|
ConfigurationWidget* buildWidget ( unsigned int flags );
|
||||||
|
@ -73,7 +73,7 @@ namespace Cfg {
|
||||||
Parameter* addParameter ( const std::string& id
|
Parameter* addParameter ( const std::string& id
|
||||||
, Parameter::Type type
|
, Parameter::Type type
|
||||||
, const std::string& value
|
, const std::string& value
|
||||||
, int priority=0 );
|
, Parameter::Priority priority=Parameter::UseDefault );
|
||||||
inline void setFlags ( unsigned int mask );
|
inline void setFlags ( unsigned int mask );
|
||||||
inline bool hasLogs ( unsigned int mask ) const;
|
inline bool hasLogs ( unsigned int mask ) const;
|
||||||
void addLog ( unsigned int mask, const std::string& id );
|
void addLog ( unsigned int mask, const std::string& id );
|
||||||
|
|
|
@ -2,14 +2,13 @@
|
||||||
// -*- C++ -*-
|
// -*- C++ -*-
|
||||||
//
|
//
|
||||||
// This file is part of the VSLSI Stand-Alone Software.
|
// This file is part of the VSLSI Stand-Alone Software.
|
||||||
// Copyright (c) UPMC/LIP6 2010-2010, All Rights Reserved
|
// Copyright (c) UPMC/LIP6 2010-2011, All Rights Reserved
|
||||||
//
|
//
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
//
|
//
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
// x-----------------------------------------------------------------x
|
// +-----------------------------------------------------------------+
|
||||||
// | |
|
|
||||||
// | C O R I O L I S |
|
// | C O R I O L I S |
|
||||||
// | C o n f i g u r a t i o n D a t a - B a s e |
|
// | C o n f i g u r a t i o n D a t a - B a s e |
|
||||||
// | |
|
// | |
|
||||||
|
@ -17,10 +16,7 @@
|
||||||
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
||||||
// | =============================================================== |
|
// | =============================================================== |
|
||||||
// | C++ Header : "./LayoutDescription.h" |
|
// | C++ Header : "./LayoutDescription.h" |
|
||||||
// | *************************************************************** |
|
// +-----------------------------------------------------------------+
|
||||||
// | U p d a t e s |
|
|
||||||
// | |
|
|
||||||
// x-----------------------------------------------------------------x
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -122,25 +118,30 @@ namespace Cfg {
|
||||||
|
|
||||||
class TabDescription {
|
class TabDescription {
|
||||||
public:
|
public:
|
||||||
inline TabDescription ( LayoutDescription*, const std::string& name );
|
inline TabDescription ( LayoutDescription*, const std::string& name, const std::string& id );
|
||||||
void addWidget ( WidgetDescription* );
|
void addWidget ( WidgetDescription* );
|
||||||
inline const std::string& getName () const;
|
inline const std::string& getName () const;
|
||||||
|
inline const std::string& getId () const;
|
||||||
inline const std::vector<WidgetDescription*>& getWidgets () const;
|
inline const std::vector<WidgetDescription*>& getWidgets () const;
|
||||||
private:
|
private:
|
||||||
LayoutDescription* _layout;
|
LayoutDescription* _layout;
|
||||||
std::string _name;
|
std::string _name;
|
||||||
|
std::string _id;
|
||||||
std::vector<WidgetDescription*> _widgets;
|
std::vector<WidgetDescription*> _widgets;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// Inline Methods.
|
// Inline Methods.
|
||||||
inline TabDescription::TabDescription ( LayoutDescription* layout, const std::string& name )
|
inline TabDescription::TabDescription ( LayoutDescription* layout, const std::string& name, const std::string& id )
|
||||||
: _layout(layout), _name(name), _widgets()
|
: _layout(layout), _name(name), _id(id), _widgets()
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
inline const std::string& TabDescription::getName () const
|
inline const std::string& TabDescription::getName () const
|
||||||
{ return _name; }
|
{ return _name; }
|
||||||
|
|
||||||
|
inline const std::string& TabDescription::getId () const
|
||||||
|
{ return _id; }
|
||||||
|
|
||||||
inline const std::vector<WidgetDescription*>& TabDescription::getWidgets () const
|
inline const std::vector<WidgetDescription*>& TabDescription::getWidgets () const
|
||||||
{ return _widgets; }
|
{ return _widgets; }
|
||||||
|
|
||||||
|
@ -155,9 +156,9 @@ namespace Cfg {
|
||||||
WidgetDescription* getWidget ( const std::string& id );
|
WidgetDescription* getWidget ( const std::string& id );
|
||||||
void addWidgetLookup ( WidgetDescription* );
|
void addWidgetLookup ( WidgetDescription* );
|
||||||
inline void addTab ( TabDescription* );
|
inline void addTab ( TabDescription* );
|
||||||
inline void addTab ( const std::string& tabName );
|
inline void addTab ( const std::string& tabName, const std::string& id );
|
||||||
inline TabDescription* getBackTab ();
|
inline TabDescription* getBackTab ();
|
||||||
TabDescription* getTab ( const std::string& tabName );
|
TabDescription* getTab ( const std::string& tabName, const std::string& id="no_id" );
|
||||||
inline const std::vector<TabDescription*>& getTabs () const;
|
inline const std::vector<TabDescription*>& getTabs () const;
|
||||||
void addRule ( const std::string& tabName );
|
void addRule ( const std::string& tabName );
|
||||||
void addTitle ( const std::string& tabName
|
void addTitle ( const std::string& tabName
|
||||||
|
@ -172,7 +173,7 @@ namespace Cfg {
|
||||||
, int span =1
|
, int span =1
|
||||||
, unsigned int flags =0 );
|
, unsigned int flags =0 );
|
||||||
ConfigurationWidget* buildWidget ( unsigned int flags );
|
ConfigurationWidget* buildWidget ( unsigned int flags );
|
||||||
void writeToStream ( std::ostream& ) const;
|
void writeToStream ( std::ostream&, const std::string& ) const;
|
||||||
private:
|
private:
|
||||||
Configuration* _configuration;
|
Configuration* _configuration;
|
||||||
std::vector<TabDescription*> _tabs;
|
std::vector<TabDescription*> _tabs;
|
||||||
|
@ -188,8 +189,8 @@ namespace Cfg {
|
||||||
inline void LayoutDescription::addTab ( TabDescription* tab )
|
inline void LayoutDescription::addTab ( TabDescription* tab )
|
||||||
{ _tabs.push_back(tab); }
|
{ _tabs.push_back(tab); }
|
||||||
|
|
||||||
inline void LayoutDescription::addTab ( const std::string& tabName )
|
inline void LayoutDescription::addTab ( const std::string& tabName, const std::string& id )
|
||||||
{ addTab ( new TabDescription(this,tabName) ); }
|
{ addTab ( new TabDescription(this,tabName,id) ); }
|
||||||
|
|
||||||
inline TabDescription* LayoutDescription::getBackTab ()
|
inline TabDescription* LayoutDescription::getBackTab ()
|
||||||
{ return _tabs.back(); }
|
{ return _tabs.back(); }
|
||||||
|
|
|
@ -2,25 +2,21 @@
|
||||||
// -*- C++ -*-
|
// -*- C++ -*-
|
||||||
//
|
//
|
||||||
// This file is part of the VSLSI Stand-Alone Software.
|
// This file is part of the VSLSI Stand-Alone Software.
|
||||||
// Copyright (c) UPMC/LIP6 2008-2010, All Rights Reserved
|
// Copyright (c) UPMC/LIP6 2008-2011, All Rights Reserved
|
||||||
//
|
//
|
||||||
// ===================================================================
|
// ===================================================================
|
||||||
//
|
//
|
||||||
// $Id$
|
// $Id$
|
||||||
//
|
//
|
||||||
// x-----------------------------------------------------------------x
|
// +-----------------------------------------------------------------+
|
||||||
// | |
|
|
||||||
// | C O R I O L I S |
|
// | C O R I O L I S |
|
||||||
// | C o n f i g u r a t i o n D a t a - B a s e |
|
// | C o n f i g u r a t i o n D a t a - B a s e |
|
||||||
// | |
|
// | |
|
||||||
// | Author : Jean-Paul CHAPUT |
|
// | Author : Jean-Paul CHAPUT |
|
||||||
// | E-mail : Jean-Paul.Chaput@asim.lip6.fr |
|
// | E-mail : Jean-Paul.Chaput@lip6.fr |
|
||||||
// | =============================================================== |
|
// | =============================================================== |
|
||||||
// | C++ Header : "./Parameter.h" |
|
// | C++ Header : "./vlsisapd/configuration/Parameter.h" |
|
||||||
// | *************************************************************** |
|
// +-----------------------------------------------------------------+
|
||||||
// | U p d a t e s |
|
|
||||||
// | |
|
|
||||||
// x-----------------------------------------------------------------x
|
|
||||||
|
|
||||||
|
|
||||||
#ifndef __CFG_CONFIGURATION_PARAMETER__
|
#ifndef __CFG_CONFIGURATION_PARAMETER__
|
||||||
|
@ -56,7 +52,8 @@ namespace Cfg {
|
||||||
, FromString = 0x80
|
, FromString = 0x80
|
||||||
, AllRequirements = HasMin|HasMax|IsFile|IsPath|NeedRestart|MustExist|TypeCheck
|
, AllRequirements = HasMin|HasMax|IsFile|IsPath|NeedRestart|MustExist|TypeCheck
|
||||||
};
|
};
|
||||||
enum Priority { ApplicationBuiltin = 1
|
enum Priority { UseDefault = 0
|
||||||
|
, ApplicationBuiltin = 1
|
||||||
, ConfigurationFile = 2
|
, ConfigurationFile = 2
|
||||||
, CommandLine = 3
|
, CommandLine = 3
|
||||||
, Interactive = 4
|
, Interactive = 4
|
||||||
|
@ -72,11 +69,14 @@ namespace Cfg {
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
static std::string typeToString ( Type );
|
static std::string typeToString ( Type );
|
||||||
|
static Priority pushDefaultPriority ( Priority );
|
||||||
|
static Priority popDefaultPriority ();
|
||||||
|
static Priority getDefaultPriority ();
|
||||||
public:
|
public:
|
||||||
Parameter ( const std::string& id
|
Parameter ( const std::string& id
|
||||||
, Type type
|
, Type type
|
||||||
, const std::string& value
|
, const std::string& value
|
||||||
, int priority=0 );
|
, Priority priority=UseDefault );
|
||||||
inline bool isFile () const;
|
inline bool isFile () const;
|
||||||
inline bool isPath () const;
|
inline bool isPath () const;
|
||||||
inline bool hasMin () const;
|
inline bool hasMin () const;
|
||||||
|
@ -105,27 +105,29 @@ namespace Cfg {
|
||||||
double asPercentage () const;
|
double asPercentage () const;
|
||||||
inline void addValue ( const std::string&, int );
|
inline void addValue ( const std::string&, int );
|
||||||
inline void addSlave ( const std::string& );
|
inline void addSlave ( const std::string& );
|
||||||
inline void setPriority ( int );
|
inline void setPriority ( Priority );
|
||||||
inline void setFlags ( int mask );
|
inline void setFlags ( int mask );
|
||||||
inline void unsetFlags ( int mask );
|
inline void unsetFlags ( int mask );
|
||||||
bool setString ( const std::string&
|
bool setString ( const std::string&
|
||||||
, unsigned int flags =AllRequirements
|
, unsigned int flags =AllRequirements
|
||||||
, int priority=ApplicationBuiltin
|
, Priority priority=UseDefault
|
||||||
);
|
);
|
||||||
bool setBool ( bool , int priority=ApplicationBuiltin );
|
bool setBool ( bool , Priority priority=UseDefault );
|
||||||
bool setInt ( int , int priority=ApplicationBuiltin );
|
bool setInt ( int , Priority priority=UseDefault );
|
||||||
bool setDouble ( double, int priority=ApplicationBuiltin );
|
bool setDouble ( double, Priority priority=UseDefault );
|
||||||
bool setPercentage ( double, int priority=ApplicationBuiltin );
|
bool setPercentage ( double, Priority priority=UseDefault );
|
||||||
inline void setMin ( int , int priority=ApplicationBuiltin );
|
void setMin ( int , Priority priority=UseDefault );
|
||||||
inline void setMax ( int , int priority=ApplicationBuiltin );
|
void setMax ( int , Priority priority=UseDefault );
|
||||||
inline void setMin ( double, int priority=ApplicationBuiltin );
|
void setMin ( double, Priority priority=UseDefault );
|
||||||
inline void setMax ( double, int priority=ApplicationBuiltin );
|
void setMax ( double, Priority priority=UseDefault );
|
||||||
inline void registerCb ( ParameterChangedCb_t );
|
inline void registerCb ( ParameterChangedCb_t );
|
||||||
private:
|
private:
|
||||||
inline void _onValueChanged ();
|
inline void _onValueChanged ();
|
||||||
|
inline bool _updatePriority ( Priority );
|
||||||
bool _doChange ( unsigned int flags, const std::string&, bool, int, double );
|
bool _doChange ( unsigned int flags, const std::string&, bool, int, double );
|
||||||
private:
|
private:
|
||||||
// Attributes.
|
// Attributes.
|
||||||
|
static std::vector<Priority> _defaultPriorities;
|
||||||
std::string _id;
|
std::string _id;
|
||||||
Type _type;
|
Type _type;
|
||||||
std::string _value;
|
std::string _value;
|
||||||
|
@ -159,7 +161,7 @@ namespace Cfg {
|
||||||
inline const std::string& Parameter::asString () const { return _value; }
|
inline const std::string& Parameter::asString () const { return _value; }
|
||||||
inline void Parameter::setFlags ( int mask ) { _flags |= mask; }
|
inline void Parameter::setFlags ( int mask ) { _flags |= mask; }
|
||||||
inline void Parameter::unsetFlags ( int mask ) { _flags &= ~mask; }
|
inline void Parameter::unsetFlags ( int mask ) { _flags &= ~mask; }
|
||||||
inline void Parameter::setPriority ( int priority ) { _priority = priority; }
|
inline void Parameter::setPriority ( Priority priority ) { _priority = priority; }
|
||||||
|
|
||||||
inline bool Parameter::checkValue ( int value ) const {
|
inline bool Parameter::checkValue ( int value ) const {
|
||||||
bool ok = not ( ( (_flags&HasMin) and (value < _minInt) )
|
bool ok = not ( ( (_flags&HasMin) and (value < _minInt) )
|
||||||
|
@ -192,35 +194,20 @@ namespace Cfg {
|
||||||
_values.push_back ( EnumValue(label,value) );
|
_values.push_back ( EnumValue(label,value) );
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Parameter::setMin ( int min, int priority )
|
|
||||||
{ if (priority >= _priority) { _priority=priority; _minInt = min; setFlags(HasMin); } }
|
|
||||||
|
|
||||||
inline void Parameter::setMax ( int max, int priority )
|
|
||||||
{ if (priority >= _priority) { _priority=priority; _maxInt = max; setFlags(HasMax); } }
|
|
||||||
|
|
||||||
inline void Parameter::setMin ( double min, int priority )
|
|
||||||
{ if (priority >= _priority) {
|
|
||||||
_priority = priority;
|
|
||||||
_minDouble = min;
|
|
||||||
setFlags ( HasMin );
|
|
||||||
if (_type==Percentage) _minDouble/=100.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void Parameter::setMax ( double max, int priority )
|
|
||||||
{ if (priority >= _priority) {
|
|
||||||
_priority = priority;
|
|
||||||
_maxDouble = max;
|
|
||||||
setFlags ( HasMax );
|
|
||||||
if (_type==Percentage) _maxDouble/=100.0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Parameter::EnumValue::EnumValue ( const std::string& label, int value )
|
inline Parameter::EnumValue::EnumValue ( const std::string& label, int value )
|
||||||
: _label(label), _value(value) { }
|
: _label(label), _value(value) { }
|
||||||
|
|
||||||
inline void Parameter::registerCb ( ParameterChangedCb_t cb ) { _callbacks.push_back(cb); }
|
inline void Parameter::registerCb ( ParameterChangedCb_t cb ) { _callbacks.push_back(cb); }
|
||||||
|
|
||||||
|
|
||||||
|
inline bool Parameter::_updatePriority ( Priority priority )
|
||||||
|
{
|
||||||
|
if ( priority == UseDefault ) priority = getDefaultPriority();
|
||||||
|
if ( priority < _priority ) return false;
|
||||||
|
_priority = priority;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
inline void Parameter::_onValueChanged ()
|
inline void Parameter::_onValueChanged ()
|
||||||
{ for ( size_t icb=0 ; icb<_callbacks.size() ; ++icb ) _callbacks[icb]( this ); }
|
{ for ( size_t icb=0 ; icb<_callbacks.size() ; ++icb ) _callbacks[icb]( this ); }
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue