wxsItemFactory::~wxsItemFactory() { if ( !m_Info ) return; ItemMapT::iterator it = ItemMap().find(m_Name); if ( it == ItemMap().end() ) return; if ( it->second!=this ) return; ItemMap().erase(it); }
/** * Create the section only if it doesn't exists */ void ConfigTree::createSection(const std::string& section) { // if we doesn't find the item, create it if (sections_.find(section) == sections_.end()) sections_[section] = ItemMap(); }
/** * Set the configItem if found, if not, *CREATE IT* * * @todo Élimier les 45,000 classes qui servent à rien pour Conf. * The true/false logic is useless here. */ void ConfigTree::setConfigTreeItem(const std::string& section, const std::string& itemName, const std::string& value) { SectionMap::iterator iter = sections_.find(section); if (iter == sections_.end()) { // Not found, create section sections_[section] = ItemMap(); iter = sections_.find(section); } ItemMap::iterator iterItem = iter->second.find(itemName); if (iterItem == iter->second.end()) { // If not found, search in our default list to find // something that would fit. std::string defaultValue = getDefaultValue(itemName); addConfigTreeItem(section, ConfigTreeItem(itemName, value, defaultValue)); return; } // Use default value if the value is empty. if (value.empty()) { iterItem->second.setValue(getDefaultValue(itemName)); return; } iterItem->second.setValue(value); return; }
wxsItemFactory::wxsItemFactory(const wxsItemInfo* Info): m_Info(Info) { m_Name = Info->ClassName; if ( Info==0 ) return; ItemMap()[m_Name] = this; }
wxsItemFactory::wxsItemFactory(const wxsItemInfo* Info,wxString ClassName): m_Info(Info) { m_Name = ClassName; if ( Info==0 ) return; ItemMap()[m_Name] = this; }
wxsItem* wxsItemFactory::Build(const wxString& Name,wxsItemResData* Data) { ItemMapT::iterator it = ItemMap().find(Name); if ( it == ItemMap().end() ) return 0; wxsItem* Item = it->second->OnBuild(Data); // Checking few things in item's info switch ( Item->GetInfo().Type ) { case wxsTTool: if ( !Item->ConvertToTool() ) { // Fake item delete Item; return 0; } break; case wxsTContainer: if ( !Item->ConvertToParent() ) { // Fake item delete Item; return 0; } break; case wxsTSizer: case wxsTSpacer: case wxsTWidget: break; case wxsTInvalid: default: delete Item; return 0; } return Item; }
/** * Add the config item only if it exists.. * If the section doesn't exists, create it */ void ConfigTree::addConfigTreeItem(const std::string& section, const ConfigTreeItem &item) { // if we doesn't find the item, create it SectionMap::iterator iter = sections_.find(section); if (iter == sections_.end()) { sections_[section] = ItemMap(); iter = sections_.find(section); } // be prudent here if (iter != sections_.end()) { std::string name(item.getName()); if (iter->second.find(name) == iter->second.end()) iter->second[name] = item; } }
const wxsItemInfo* wxsItemFactory::GetNextInfo() { if ( m_Iter==ItemMap().end() ) return 0; ++m_Iter; return (m_Iter==ItemMap().end()) ? 0 : m_Iter->second->m_Info; }
const wxsItemInfo* wxsItemFactory::GetFirstInfo() { m_Iter = ItemMap().begin(); return (m_Iter==ItemMap().end()) ? 0 : m_Iter->second->m_Info; }
const wxsItemInfo* wxsItemFactory::GetInfo(const wxString& Name) { ItemMapT::iterator it = ItemMap().find(Name); if ( it == ItemMap().end() ) return 0; return it->second->m_Info; }