Linux multi-monitor fullscreen support
[ryzomcore.git] / nel / tools / 3d / object_viewer / scheme_manager.cpp
blob7c3d7a3ec6a7da25c1125c273235eb4aa4f3a8cc
1 // NeL - MMORPG Framework <http://dev.ryzom.com/projects/nel/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 #include "std_afx.h"
18 #include "scheme_manager.h"
19 #include "nel/3d/ps_attrib_maker.h"
21 CSchemeManager SchemeManager;
24 CSchemeManager::~CSchemeManager()
26 for(TSchemeMap::iterator it = _SchemeMap.begin(); it != _SchemeMap.end(); ++it)
28 delete it->second.second;
33 void CSchemeManager::insertScheme(const std::string &name, NL3D::CPSAttribMakerBase *scheme)
35 nlassert(scheme);
36 TSchemeInfo si(std::string(name), scheme);
37 _SchemeMap.insert(TSchemeMap::value_type(std::string(scheme->getType()), si));
40 void CSchemeManager::getSchemes(const std::string &type, std::vector<TSchemeInfo> &dest)
42 TSchemeMap::const_iterator lbd = _SchemeMap.lower_bound(type), ubd = _SchemeMap.upper_bound(type);
43 dest.clear();
44 for (TSchemeMap::const_iterator it = lbd; it != ubd; ++it)
46 dest.push_back(it->second);
50 void CSchemeManager::serial(NLMISC::IStream &f)
53 f.serialCheck((uint32) '_GNM');
54 f.serialCheck((uint32) 'MHCS');
55 f.serialVersion(1);
56 if (!f.isReading())
58 sint32 size = (sint32)_SchemeMap.size();
59 f.serial(size);
60 for (TSchemeMap::iterator smIt = _SchemeMap.begin(); smIt != _SchemeMap.end(); ++smIt)
62 f.serial(smIt->second.first); // name
63 f.serialPolyPtr(smIt->second.second); // scheme
66 else
68 _SchemeMap.clear();
70 std::string name;
71 NL3D::CPSAttribMakerBase *scheme = NULL;
72 sint32 size;
73 f.serial(size);
74 for (sint32 k = 0; k < size; ++k)
76 f.serial(name);
77 f.serialPolyPtr(scheme);
78 insertScheme(name, scheme);
85 void CSchemeManager::swap(CSchemeManager &other)
87 this->_SchemeMap.swap(other._SchemeMap);
90 void CSchemeManager::remove(NL3D::CPSAttribMakerBase *am)
92 TSchemeMap::iterator smIt;
93 for (smIt = _SchemeMap.begin(); smIt != _SchemeMap.end(); ++smIt)
95 if (smIt->second.second == am) break;
97 if (smIt != _SchemeMap.end())
99 delete smIt->second.second; // delete the scheme
100 // delet from the collection
101 _SchemeMap.erase(smIt);
107 // rename a scheme, given a pointer on it
108 void CSchemeManager::rename(NL3D::CPSAttribMakerBase *am, const std::string &newName)
110 TSchemeMap::iterator smIt;
111 for (smIt = _SchemeMap.begin(); smIt != _SchemeMap.end(); ++smIt)
113 if (smIt->second.second == am) break;
115 if (smIt != _SchemeMap.end())
117 smIt->second.first = newName;