diff --git a/lima_common/src/common/MediaticData/mediaticData.cpp b/lima_common/src/common/MediaticData/mediaticData.cpp index bed1002d6..e9ab1508c 100644 --- a/lima_common/src/common/MediaticData/mediaticData.cpp +++ b/lima_common/src/common/MediaticData/mediaticData.cpp @@ -902,38 +902,14 @@ void MediaticDataPrivate::initEntityTypes(XMLConfigurationFileParser& configPars #endif } } - catch(NoSuchList& ) + catch(NoSuchList& e) { - // no simple list: may be list of items with attributes (to deal with isA relations of entities) - auto& items = groupConf.getListOfItems("entityList"); - for (const auto& i: items) - { - auto entityName = QString::fromStdString(i.getName()); -#ifdef DEBUG_CD - LDEBUG << "initEntityTypes: add entityType " << i.getName() << " in group " << groupName; -#endif - auto ent = addEntity(groupName, entityName); -#ifdef DEBUG_CD - LDEBUG << "initEntityTypes: type is " << ent; -#endif - if (i.hasAttribute(QLatin1String("isA"))) - { - auto parentName = utf8stdstring2limastring(i.getAttribute("isA")); - EntityType parent; - try - { - parent = getEntityType(groupName, parentName); - #ifdef DEBUG_CD - LDEBUG << "initEntityTypes: add parent link:" << ent << "->" << parent; - #endif - } - catch (const LimaException& e) - { - LIMA_EXCEPTION( "Unknown entity type" << groupName << parentName); - } - addEntityParentLink(ent, parent); - } - } + MDATALOGINIT; + QString errorString; + QTextStream qts(&errorString); + qts << "missing list 'entityList' in entity types configuration:" << e.what(); + LERROR << errorString; + throw InvalidConfiguration(errorString.toStdString()); } } } diff --git a/lima_common/src/common/XMLConfigurationFiles/CMakeLists.txt b/lima_common/src/common/XMLConfigurationFiles/CMakeLists.txt index 6d21872ae..41a28f175 100644 --- a/lima_common/src/common/XMLConfigurationFiles/CMakeLists.txt +++ b/lima_common/src/common/XMLConfigurationFiles/CMakeLists.txt @@ -14,7 +14,6 @@ SET(lima-common-xmlconfigurationfiles_LIB_SRCS moduleConfigurationStructure.cpp xmlConfigurationFileParser.cpp xmlConfigurationFileReader.cpp - itemWithAttributes.cpp ) add_library(lima-common-xmlconfigurationfiles SHARED ${lima-common-xmlconfigurationfiles_LIB_SRCS}) @@ -38,7 +37,6 @@ install(FILES groupConfigurationStructure.h xmlConfigurationFileExceptions.h moduleConfigurationStructure.h - itemWithAttributes.h DESTINATION include/common/XMLConfigurationFiles COMPONENT devel ) diff --git a/lima_common/src/common/XMLConfigurationFiles/configurationStructure.cpp b/lima_common/src/common/XMLConfigurationFiles/configurationStructure.cpp index ed22f58d3..4387e5a34 100644 --- a/lima_common/src/common/XMLConfigurationFiles/configurationStructure.cpp +++ b/lima_common/src/common/XMLConfigurationFiles/configurationStructure.cpp @@ -210,41 +210,6 @@ getGroupConf(const std::string& moduleName, return (*itC).second.getGroupNamed(group) ; } -void ConfigurationStructure:: -addListOfItemsForModuleAndGroup(const std::string &listName, - const std::string& moduleName, - const std::string& group) -{ - getGroupConf(moduleName,group).addListOfItems(listName); -} - -void ConfigurationStructure:: -addItemInListOfItemsForModuleAndGroup(const ItemWithAttributes& item, - const std::string &listName, - const std::string& moduleName, - const std::string& group) -{ - getGroupConf(moduleName,group).addItemInListOfItems(listName,item); -} - -void ConfigurationStructure:: -addMapOfItemsForModuleAndGroup(const std::string &mapName, - const std::string& moduleName, - const std::string& group) -{ - getGroupConf(moduleName,group).addMapOfItems(mapName); -} - -void ConfigurationStructure:: -addEntryInMapOfItemsForModuleAndGroup(const std::string& key, - const ItemWithAttributes& item, - const std::string& mapName, - const std::string& moduleName, - const std::string& group) -{ - getGroupConf(moduleName,group).addEntryInMapOfItems(mapName,key,item); -} - std::ostream& operator<<(std::ostream &os, const ConfigurationStructure& conf) { for (ConfigurationStructure::const_iterator it = conf.begin(); it != conf.end(); it++) @@ -255,70 +220,6 @@ std::ostream& operator<<(std::ostream &os, const ConfigurationStructure& conf) return os; } - -void ConfigurationStructure:: -changeListToListOfItems(const std::string &listName, - const std::string& moduleName, - const std::string& group) -{ - getGroupConf(moduleName,group).changeListToListOfItems(listName); -} - -void ConfigurationStructure:: -changeMapToMapOfItems(const std::string &mapName, - const std::string& moduleName, - const std::string& group) -{ - getGroupConf(moduleName,group).changeMapToMapOfItems(mapName); -} - -void ConfigurationStructure::addListOfItemsForModuleAndGroup(const QString &listName, - const QString& moduleName, - const QString& group) -{ - addListOfItemsForModuleAndGroup(listName.toStdString(), moduleName.toStdString(), group.toStdString()); -} - -void ConfigurationStructure::addItemInListOfItemsForModuleAndGroup(const ItemWithAttributes& item, - const QString &listName, - const QString& moduleName, - const QString& group) -{ - addItemInListOfItemsForModuleAndGroup(item, listName.toStdString(), moduleName.toStdString(), group.toStdString()); -} - -void ConfigurationStructure::addMapOfItemsForModuleAndGroup(const QString &mapName, - const QString& moduleName, - const QString& group) -{ - addMapOfItemsForModuleAndGroup(mapName.toStdString(), moduleName.toStdString(), group.toStdString()); -} - -void ConfigurationStructure::addEntryInMapOfItemsForModuleAndGroup(const QString& entryKey, - const ItemWithAttributes& entryValue, - const QString& mapName, - const QString& moduleName, - const QString& groupName) -{ - addEntryInMapOfItemsForModuleAndGroup(entryKey.toStdString(), entryValue, mapName.toStdString(), - moduleName.toStdString(), groupName.toStdString()); -} - -void ConfigurationStructure::changeListToListOfItems(const QString &listName, - const QString& moduleName, - const QString& group) -{ - changeListToListOfItems(listName.toStdString(), moduleName.toStdString(), group.toStdString()); -} - -void ConfigurationStructure::changeMapToMapOfItems(const QString &mapName, - const QString& moduleName, - const QString& group) -{ - changeMapToMapOfItems(mapName.toStdString(), moduleName.toStdString(), group.toStdString()); -} - - } //closing namespace XMLConfigurationFiles } //closing namespace Common } //closing namespace Lima diff --git a/lima_common/src/common/XMLConfigurationFiles/configurationStructure.h b/lima_common/src/common/XMLConfigurationFiles/configurationStructure.h index 7940d1387..c8c7ac061 100644 --- a/lima_common/src/common/XMLConfigurationFiles/configurationStructure.h +++ b/lima_common/src/common/XMLConfigurationFiles/configurationStructure.h @@ -51,29 +51,6 @@ class LIMA_XMLCONFIGURATIONFILES_EXPORT ConfigurationStructure : public std::map void addAttributeForGroupInModule(const std::string& attKey,const std::string& attValue,const std::string& groupName,const std::string& moduleName); - void addListOfItemsForModuleAndGroup(const std::string &listName, - const std::string& moduleName, - const std::string& group); - void addItemInListOfItemsForModuleAndGroup(const ItemWithAttributes& item, - const std::string &listName, - const std::string& moduleName, - const std::string& group); - void addMapOfItemsForModuleAndGroup(const std::string &mapName, - const std::string& moduleName, - const std::string& group); - void addEntryInMapOfItemsForModuleAndGroup(const std::string& entryKey, - const ItemWithAttributes& entryValue, - const std::string& mapName, - const std::string& moduleName, - const std::string& groupName); - - void changeListToListOfItems(const std::string &listName, - const std::string& moduleName, - const std::string& group); - void changeMapToMapOfItems(const std::string &mapName, - const std::string& moduleName, - const std::string& group); - void addParamValuePairForModuleAndGroup(const QString ¶m, const QString &value, const QString &module, @@ -100,29 +77,6 @@ class LIMA_XMLCONFIGURATIONFILES_EXPORT ConfigurationStructure : public std::map const QString& moduleName); - void addListOfItemsForModuleAndGroup(const QString &listName, - const QString& moduleName, - const QString& group); - void addItemInListOfItemsForModuleAndGroup(const ItemWithAttributes& item, - const QString &listName, - const QString& moduleName, - const QString& group); - void addMapOfItemsForModuleAndGroup(const QString &mapName, - const QString& moduleName, - const QString& group); - void addEntryInMapOfItemsForModuleAndGroup(const QString& entryKey, - const ItemWithAttributes& entryValue, - const QString& mapName, - const QString& moduleName, - const QString& groupName); - - void changeListToListOfItems(const QString &listName, - const QString& moduleName, - const QString& group); - void changeMapToMapOfItems(const QString &mapName, - const QString& moduleName, - const QString& group); - private: GroupConfigurationStructure& diff --git a/lima_common/src/common/XMLConfigurationFiles/groupConfigurationStructure.cpp b/lima_common/src/common/XMLConfigurationFiles/groupConfigurationStructure.cpp index d0a6535ef..a08baae79 100644 --- a/lima_common/src/common/XMLConfigurationFiles/groupConfigurationStructure.cpp +++ b/lima_common/src/common/XMLConfigurationFiles/groupConfigurationStructure.cpp @@ -40,23 +40,16 @@ std::ostream& operator<<(std::ostream& os, const MSS& mss); typedef std::map< std::string, std::deque > MSDS; std::ostream& operator<<(std::ostream& os, const MSDS& mss); -typedef std::map< std::string, std::deque > MSDI; -std::ostream& operator<<(std::ostream& os, const MSDI& msdi); - typedef std::map< std::string, std::map > MSMSS; std::ostream& operator<<(std::ostream& os, const MSMSS& msmss); -typedef std::map< std::string, std::map > MSMSI; -std::ostream& operator<<(std::ostream& os, const MSMSI& msmsi); - - class GroupConfigurationStructurePrivate { friend class GroupConfigurationStructure; friend std::ostream& operator<<(std::ostream& os, const GroupConfigurationStructure& dgcs); GroupConfigurationStructurePrivate() {} - // GroupConfigurationStructurePrivate(const QJsonObject& group); + GroupConfigurationStructurePrivate(const QJsonObject& group); GroupConfigurationStructurePrivate(const std::string& name); GroupConfigurationStructurePrivate(const GroupConfigurationStructurePrivate& group); GroupConfigurationStructurePrivate& operator=(const GroupConfigurationStructurePrivate& group); @@ -66,8 +59,6 @@ class GroupConfigurationStructurePrivate MSDS m_lists; MSS m_attributes; MSMSS m_maps; - MSDI m_listsOfItems; - MSMSI m_mapsOfItems; std::string m_groupName; friend class XMLConfigurationFileHandler; @@ -81,32 +72,28 @@ class GroupConfigurationStructurePrivate "list_1": ["i1", "i2", "i3"], } */ -// GroupConfigurationStructurePrivate::GroupConfigurationStructurePrivate( -// const QJsonObject& group) : -// m_params() -// // m_lists(group.m_lists), -// // m_attributes(group.m_attributes), -// // m_maps(group.m_maps), -// // m_listsOfItems(group.m_listsOfItems), -// // m_mapsOfItems(group.m_mapsOfItems), -// // m_groupName(group.m_groupName) -// { -// for(const QString& key: group["params"].toObject().keys()) -// { -// auto param = QString::fromStdString("params"); -// auto value = group[param][key].toString(); -// m_params[key.toStdString()] = value.toStdString(); -// } -// // TODO finish the implementation -// } +GroupConfigurationStructurePrivate::GroupConfigurationStructurePrivate( + const QJsonObject& group) : + m_params() + // m_lists(group.m_lists), + // m_attributes(group.m_attributes), + // m_maps(group.m_maps), + // m_groupName(group.m_groupName) +{ + for(const QString& key: group["params"].toObject().keys()) + { + auto param = QString::fromStdString("params"); + auto value = group[param][key].toString(); + m_params[key.toStdString()] = value.toStdString(); + } + // TODO finish the implementation +} GroupConfigurationStructurePrivate::GroupConfigurationStructurePrivate(const std::string& name) : m_params(), m_lists(), m_attributes(), m_maps(), - m_listsOfItems(), - m_mapsOfItems(), m_groupName(name) {} @@ -115,8 +102,6 @@ GroupConfigurationStructurePrivate::GroupConfigurationStructurePrivate(const Gro m_lists(group.m_lists), m_attributes(group.m_attributes), m_maps(group.m_maps), - m_listsOfItems(group.m_listsOfItems), - m_mapsOfItems(group.m_mapsOfItems), m_groupName(group.m_groupName) {} @@ -126,8 +111,6 @@ GroupConfigurationStructurePrivate& GroupConfigurationStructurePrivate::operator m_lists=group.m_lists; m_attributes=group.m_attributes; m_maps=group.m_maps; - m_listsOfItems=group.m_listsOfItems; - m_mapsOfItems=group.m_mapsOfItems; m_groupName=group.m_groupName; return *this; } @@ -143,11 +126,11 @@ GroupConfigurationStructure::GroupConfigurationStructure() : m_d(new GroupConfig } -// GroupConfigurationStructure::GroupConfigurationStructure(const QJsonObject& group) : -// m_d(new GroupConfigurationStructurePrivate(group)) -// { -// -// } +GroupConfigurationStructure::GroupConfigurationStructure(const QJsonObject& group) : + m_d(new GroupConfigurationStructurePrivate(group)) +{ + +} GroupConfigurationStructure::GroupConfigurationStructure(const std::string& name) : m_d(new GroupConfigurationStructurePrivate(name)) @@ -352,7 +335,8 @@ void GroupConfigurationStructure::addMap(const std::string& mapName) m_d->m_maps.insert(make_pair(mapName,MSS())); } -void GroupConfigurationStructure::addEntryInMap(const std::string& mapName,const std::string& key,const std::string& value) +void GroupConfigurationStructure::addEntryInMap( + const std::string& mapName,const std::string& key,const std::string& value) { MSMSS::iterator it=m_d->m_maps.find(mapName); if (it == m_d->m_maps.end()) @@ -360,89 +344,6 @@ void GroupConfigurationStructure::addEntryInMap(const std::string& mapName,const (it->second)[key]=value; } -std::deque& GroupConfigurationStructure::getListOfItems(const std::string& key) -{ - MSDI::iterator it = m_d->m_listsOfItems.find(key); - if (it == m_d->m_listsOfItems.end()) - throw NoSuchList(m_d->m_groupName+"["+key+"]"); - return (*it).second; -} - -std::map& GroupConfigurationStructure::getMapOfItems(const std::string& key) -{ - MSMSI::iterator it = m_d->m_mapsOfItems.find(key); - if (it == m_d->m_mapsOfItems.end()) - throw NoSuchMap(m_d->m_groupName+"["+key+"]"); - return it->second; -} - -void GroupConfigurationStructure::addListOfItems(const std::string& listName) -{ - m_d->m_listsOfItems[listName]=std::deque(0); -} - -void GroupConfigurationStructure::addItemInListOfItems(const std::string& key, - const ItemWithAttributes& item) -{ - MSDI::iterator it = m_d->m_listsOfItems.find(key); - if (it == m_d->m_listsOfItems.end()) - throw NoSuchList(m_d->m_groupName+"["+key+"]"); - (*it).second.push_back(item); -} - -void GroupConfigurationStructure::addMapOfItems(const std::string& mapName) -{ - m_d->m_mapsOfItems[mapName]=std::map(); -} - -void GroupConfigurationStructure::addEntryInMapOfItems(const std::string& mapName, - const std::string& key, - const ItemWithAttributes& item) -{ - MSMSI::iterator it = m_d->m_mapsOfItems.find(mapName); - if (it == m_d->m_mapsOfItems.end()) - throw NoSuchMap(m_d->m_groupName+"["+mapName+"]"); - ((*it).second)[key]=item; -} - -void GroupConfigurationStructure::changeListToListOfItems(const std::string &listName) -{ - MSDS::iterator it = m_d->m_lists.find(listName); - if (it == m_d->m_lists.end()) - throw NoSuchList(m_d->m_groupName+"["+listName+"]"); - - // create new list of items - m_d->m_listsOfItems[listName]=deque(0); - deque& newList=m_d->m_listsOfItems[listName]; - for (deque::const_iterator - entry=(*it).second.begin(),entry_end=(*it).second.end(); - entry!=entry_end; entry++) { - newList.push_back(ItemWithAttributes((*entry))); - } - - // erase old map - m_d-> m_lists.erase(it); -} - -void GroupConfigurationStructure::changeMapToMapOfItems(const std::string &mapName) -{ - MSMSS::iterator it = m_d->m_maps.find(mapName); - if (it == m_d->m_maps.end()) - throw NoSuchMap(m_d->m_groupName+"["+mapName+"]"); - - // create new map of items - m_d->m_mapsOfItems[mapName]=map(); - map& newMap=m_d->m_mapsOfItems[mapName]; - for (map::const_iterator - entry=(*it).second.begin(),entry_end=(*it).second.end(); - entry!=entry_end; entry++) { - newMap[(*entry).first]=ItemWithAttributes((*entry).second); - } - - // erase old map - m_d->m_maps.erase(it); -} - // void GroupConfigurationStructure::addAttribute(const QString& key,const QString& value) // { // addAttribute(key.toStdString(), value.toStdString()); @@ -472,48 +373,6 @@ void GroupConfigurationStructure::changeMapToMapOfItems(const std::string &mapNa // { // addEntryInMap(mapName.toStdString(), key.toStdString(), value.toStdString()); // } -// -// std::deque& GroupConfigurationStructure::getListOfItems(const QString& key) -// { -// return getListOfItems(key.toStdString()); -// } -// -// std::map& GroupConfigurationStructure::getMapOfItems(const QString& key) -// { -// return getMapOfItems(key.toStdString()); -// } -// -// void GroupConfigurationStructure::addListOfItems(const QString& listName) -// { -// addListOfItems(listName.toStdString()); -// } -// -// void GroupConfigurationStructure::addItemInListOfItems(const QString& key, const ItemWithAttributes& item) -// { -// addItemInListOfItems(key.toStdString(), item); -// } -// -// void GroupConfigurationStructure::addMapOfItems(const QString& mapName) -// { -// addMapOfItems(mapName.toStdString()); -// } -// -// void GroupConfigurationStructure::addEntryInMapOfItems(const QString& mapName, -// const QString& key, -// const ItemWithAttributes& item) -// { -// addEntryInMapOfItems(mapName.toStdString(), key.toStdString(), item); -// } -// -// void GroupConfigurationStructure::changeListToListOfItems(const QString &listName) -// { -// changeListToListOfItems(listName.toStdString()); -// } -// -// void GroupConfigurationStructure::changeMapToMapOfItems(const QString &mapName) -// { -// changeMapToMapOfItems(mapName.toStdString()); -// } std::ostream& operator<<(std::ostream& os, const GroupConfigurationStructure& dgcs) { @@ -521,9 +380,7 @@ std::ostream& operator<<(std::ostream& os, const GroupConfigurationStructure& dg << "Attributes : " << dgcs.m_d->m_attributes << endl << "Params : " << dgcs.m_d->m_params << endl << "Lists : " << dgcs.m_d->m_lists << endl - << "Maps : " << dgcs.m_d->m_maps << endl - << "ListsOfItems : " << dgcs.m_d->m_listsOfItems << endl - << "MapsOfItems : " << dgcs.m_d->m_mapsOfItems << endl; + << "Maps : " << dgcs.m_d->m_maps << endl; } std::ostream& operator<<(std::ostream& os, const MSS& mss) @@ -565,49 +422,6 @@ std::ostream& operator<<(std::ostream& os, const MSMSS& msmss) return os; } -std::ostream& operator<<(std::ostream& os, const MSDI& msdi) -{ - for (MSDI::const_iterator it=msdi.begin();it!=msdi.end();it++) - { - os << it->first << " { "; - auto di=it->second; - for (std::deque::const_iterator it2=di.begin();it2!=di.end();it2++) - { - os << it2->getName() << "["; - std::map attributes = it2->getAttributes(); - for(auto it3 = attributes.begin(); it3!=attributes.end(); it3++) - { - os << "@" << it3->first << "=" << it3->second << ", "; - } - os << "] "; - } - os << "}" << endl; - } - return os; -} - -std::ostream& operator<<(std::ostream& os, const MSMSI& msmsi) -{ - for (MSMSI::const_iterator it=msmsi.begin();it!=msmsi.end();it++) - { - os << it->first << " { "; - auto msi=it->second; - for (std::map::const_iterator it2=msi.begin();it2!=msi.end();it2++) - { - os << it2->first << "=>" << it2->second.getName() << "["; - std::map attributes = it2->second.getAttributes(); - for(auto it3 = attributes.begin(); it3!=attributes.end(); it3++) - { - os << "@" << it3->first << "=" << it3->second << ", "; - } - os << "] "; - } - os << "}" << endl; - } - return os; -} - - } // closing namespace XMLConfigurationFiles } // closing namespace Common } // closing namespace Lima diff --git a/lima_common/src/common/XMLConfigurationFiles/groupConfigurationStructure.h b/lima_common/src/common/XMLConfigurationFiles/groupConfigurationStructure.h index 02269f097..3f303651b 100644 --- a/lima_common/src/common/XMLConfigurationFiles/groupConfigurationStructure.h +++ b/lima_common/src/common/XMLConfigurationFiles/groupConfigurationStructure.h @@ -18,7 +18,6 @@ #include "common/LimaCommon.h" #include "xmlConfigurationFileExceptions.h" -#include "itemWithAttributes.h" #include #include #include @@ -33,7 +32,7 @@ class GroupConfigurationStructurePrivate; class LIMA_XMLCONFIGURATIONFILES_EXPORT GroupConfigurationStructure { public: GroupConfigurationStructure(); - // GroupConfigurationStructure(const QJsonObject& group); + GroupConfigurationStructure(const QJsonObject& group); GroupConfigurationStructure(const std::string& name); GroupConfigurationStructure(const QString& name); GroupConfigurationStructure(const GroupConfigurationStructure& group); @@ -56,19 +55,6 @@ class LIMA_XMLCONFIGURATIONFILES_EXPORT GroupConfigurationStructure { void addMap(const std::string& mapName); void addEntryInMap(const std::string& mapName,const std::string& key,const std::string& value); - std::deque& getListOfItems(const std::string& key); - std::map& getMapOfItems(const std::string& key); - void addListOfItems(const std::string& listName); - void addItemInListOfItems(const std::string& listName, - const ItemWithAttributes& item); - void addMapOfItems(const std::string& mapName); - void addEntryInMapOfItems(const std::string& mapName, - const std::string& key, - const ItemWithAttributes& item); - - void changeListToListOfItems(const std::string &listName); - void changeMapToMapOfItems(const std::string &mapName); - // QString getNameQ(); // QString getAttribute(const QString& key); // QString getParamsValueAtKey(const QString& key); @@ -81,19 +67,6 @@ class LIMA_XMLCONFIGURATIONFILES_EXPORT GroupConfigurationStructure { // void addItemInListNamed(const QString& item, const QString& listName); // void addMap(const QString& mapName); // void addEntryInMap(const QString& mapName,const QString& key,const QString& value); -// -// std::deque& getListOfItems(const QString& key); -// std::map& getMapOfItems(const QString& key); -// void addListOfItems(const QString& listName); -// void addItemInListOfItems(const QString& listName, -// const ItemWithAttributes& item); -// void addMapOfItems(const QString& mapName); -// void addEntryInMapOfItems(const QString& mapName, -// const QString& key, -// const ItemWithAttributes& item); -// -// void changeListToListOfItems(const QString &listName); -// void changeMapToMapOfItems(const QString &mapName); friend LIMA_XMLCONFIGURATIONFILES_EXPORT std::ostream& operator<<(std::ostream& os, const GroupConfigurationStructure& dgcs); diff --git a/lima_common/src/common/XMLConfigurationFiles/itemWithAttributes.cpp b/lima_common/src/common/XMLConfigurationFiles/itemWithAttributes.cpp deleted file mode 100644 index 78ce0fa58..000000000 --- a/lima_common/src/common/XMLConfigurationFiles/itemWithAttributes.cpp +++ /dev/null @@ -1,145 +0,0 @@ -// Copyright 2002-2013 CEA LIST -// SPDX-FileCopyrightText: 2022 CEA LIST -// -// SPDX-License-Identifier: MIT - -/************************************************************************ - * - * @file itemWithAttributes.cpp - * @author besancon (romaric.besancon@cea.fr) - * @date Thu Dec 8 2005 - * @version $Id$ - * copyright Copyright (C) 2005-2012 by CEA LIST - * - ***********************************************************************/ - -#include "itemWithAttributes.h" -#include "xmlConfigurationFileExceptions.h" - -namespace Lima { -namespace Common { -namespace XMLConfigurationFiles { - -class ItemWithAttributesPrivate -{ - friend class ItemWithAttributes; - - ItemWithAttributesPrivate(); - ItemWithAttributesPrivate(const std::string& name); - ItemWithAttributesPrivate(const ItemWithAttributesPrivate& item); - ItemWithAttributesPrivate& operator=(const ItemWithAttributesPrivate& item); - ~ItemWithAttributesPrivate(); - - std::string m_name; - std::map m_attributes; -}; - -ItemWithAttributesPrivate::ItemWithAttributesPrivate(): -m_name(""), -m_attributes() -{ -} - -ItemWithAttributesPrivate::ItemWithAttributesPrivate(const std::string& name): -m_name(name), -m_attributes() -{ -} - -ItemWithAttributesPrivate::ItemWithAttributesPrivate(const ItemWithAttributesPrivate& item): -m_name(item.m_name), -m_attributes(item.m_attributes) -{ -} - -ItemWithAttributesPrivate& ItemWithAttributesPrivate::operator=(const ItemWithAttributesPrivate& item) -{ - m_name = item.m_name; - m_attributes = item.m_attributes; - return *this; -} - -ItemWithAttributesPrivate::~ItemWithAttributesPrivate() { -} - -//*********************************************************************** -// constructors and destructors -ItemWithAttributes::ItemWithAttributes(): - m_d(new ItemWithAttributesPrivate()) -{ -} - -ItemWithAttributes::ItemWithAttributes(const std::string& name): - m_d(new ItemWithAttributesPrivate(name)) -{ -} - -ItemWithAttributes::ItemWithAttributes(const QString& name): - m_d(new ItemWithAttributesPrivate(name.toStdString())) -{ -} - -ItemWithAttributes::ItemWithAttributes(const ItemWithAttributes& item): - m_d(new ItemWithAttributesPrivate(*item.m_d)) -{ -} - -ItemWithAttributes& ItemWithAttributes::operator=(const ItemWithAttributes& item) -{ - *m_d = *item.m_d; - return *this; -} - -ItemWithAttributes::~ItemWithAttributes() -{ - delete m_d; -} - -//*********************************************************************** -const std::string& ItemWithAttributes::getName() const { return m_d->m_name; } - -uint64_t ItemWithAttributes::nbAttributes() const { return m_d->m_attributes.size(); } - -const std::map& ItemWithAttributes::getAttributes() const - { return m_d->m_attributes; } - -const std::string& ItemWithAttributes:: -getAttribute(const std::string& attributeName) const -{ - std::map::const_iterator - it=m_d->m_attributes.find(attributeName); - if (it == m_d->m_attributes.end()) { - throw NoSuchAttribute(m_d->m_name+"["+attributeName+"]"); - } - return (*it).second; -} - -bool ItemWithAttributes:: -hasAttribute(const std::string& attributeName) const -{ - std::map::const_iterator - it=m_d->m_attributes.find(attributeName); - return !(it == m_d->m_attributes.end()); -} - -void ItemWithAttributes:: -addAttribute(const std::string& attributeName, - const std::string& value) -{ - m_d->m_attributes.insert(std::make_pair(attributeName,value)); -} - -bool ItemWithAttributes::hasAttribute(const QString& attributeName) const -{ - return hasAttribute(attributeName.toStdString()); -} - -void ItemWithAttributes::addAttribute(const QString& attributeName, const QString& value) -{ - addAttribute(attributeName.toStdString(), value.toStdString()); -} - - -} // end namespace -} // end namespace -} // end namespace diff --git a/lima_common/src/common/XMLConfigurationFiles/itemWithAttributes.h b/lima_common/src/common/XMLConfigurationFiles/itemWithAttributes.h deleted file mode 100644 index c0dcc2c25..000000000 --- a/lima_common/src/common/XMLConfigurationFiles/itemWithAttributes.h +++ /dev/null @@ -1,62 +0,0 @@ -// Copyright 2002-2013 CEA LIST -// SPDX-FileCopyrightText: 2022 CEA LIST -// -// SPDX-License-Identifier: MIT - -/************************************************************************ - * - * @file itemWithAttributes.h - * @author besancon (romaric.besancon@cea.fr) - * @date Thu Dec 8 2005 - * @version $Id$ - * copyright Copyright (C) 2005-2012 by CEA LIST - * Project XMLConfigurationFile - * - * @brief generic named item with attributes - * - * - ***********************************************************************/ - -#ifndef ITEMWITHATTRIBUTES_H -#define ITEMWITHATTRIBUTES_H - -#include "common/LimaCommon.h" -#include -#include - -namespace Lima { -namespace Common { -namespace XMLConfigurationFiles { - -class ItemWithAttributesPrivate; -class LIMA_XMLCONFIGURATIONFILES_EXPORT ItemWithAttributes -{ - public: - ItemWithAttributes(); - ItemWithAttributes(const std::string& name); - ItemWithAttributes(const QString& name); - ItemWithAttributes(const ItemWithAttributes& item); - ItemWithAttributes& operator=(const ItemWithAttributes& item); - ~ItemWithAttributes(); - - const std::string& getName() const; - const std::string& getAttribute(const std::string& attributeName) const; - bool hasAttribute(const std::string& attributeName) const; - uint64_t nbAttributes() const; - void addAttribute(const std::string& attributeName, - const std::string& value); - const std::map& getAttributes() const; - - bool hasAttribute(const QString& attributeName) const; - void addAttribute(const QString& attributeName, - const QString& value); - -private: - ItemWithAttributesPrivate* m_d; -}; - -} // end namespace -} // end namespace -} // end namespace - -#endif diff --git a/lima_common/src/common/XMLConfigurationFiles/xmlConfigurationFileHandler.cpp b/lima_common/src/common/XMLConfigurationFiles/xmlConfigurationFileHandler.cpp index dd4ab573d..221658fba 100644 --- a/lima_common/src/common/XMLConfigurationFiles/xmlConfigurationFileHandler.cpp +++ b/lima_common/src/common/XMLConfigurationFiles/xmlConfigurationFileHandler.cpp @@ -151,52 +151,23 @@ bool XMLConfigurationFileHandler::startElement( const QString & , const QString { m_listName = toString(attributes.value("name")); LTRACE << "list name is " << m_listName; - - m_firstItem=true; - m_itemWithAttributes=false; } else if (stringName == "item") { uint32_t nbAtt=attributes.length(); if (m_firstItem) { - // decide if list is simple list or list of items with attributes - if (nbAtt==1) { - LTRACE << "add simple list "<< m_listName; - m_configuration.addListNamedForModuleAndGroup(m_listName, m_moduleName, m_groupName); - } - else { - LTRACE << "add list of items with attributes"<< m_listName; - m_configuration.addListOfItemsForModuleAndGroup(m_listName, m_moduleName, m_groupName); - m_itemWithAttributes=true; - } + LTRACE << "add simple list "<< m_listName; + m_configuration.addListNamedForModuleAndGroup(m_listName, m_moduleName, m_groupName); m_firstItem=false; } - else if (nbAtt>1 && !m_itemWithAttributes) { - // was indeed in list of item with attributes => has to change - m_configuration.changeListToListOfItems(m_listName,m_moduleName,m_groupName); - m_itemWithAttributes=true; - } - if (m_itemWithAttributes) { - string itemName=toString(attributes.value("value")); - ItemWithAttributes item(itemName); - for (uint32_t i=0; i simple map - LTRACE << "add map list "<< m_mapName.c_str(); - m_configuration.addMapNamedForModuleAndGroup(m_mapName,m_moduleName,m_groupName); - } - else { - LTRACE << "add map of items with attributes "<< m_mapName; - m_configuration.addMapOfItemsForModuleAndGroup(m_mapName,m_moduleName,m_groupName); - m_itemWithAttributes=true; - } + LTRACE << "add map list "<< m_mapName.c_str(); + m_configuration.addMapNamedForModuleAndGroup(m_mapName,m_moduleName,m_groupName); m_firstItem=false; } - else if (nbAtt>2 && !m_itemWithAttributes) { - // was indeed in list of item with attributes => has to change - m_configuration.changeMapToMapOfItems(m_mapName,m_moduleName,m_groupName); - m_itemWithAttributes=true; - } - if (m_itemWithAttributes) { - string key=toString(attributes.value("key")); - string value=toString(attributes.value("value")); - ItemWithAttributes item(value); - for (uint32_t i=1; i