VR-Forces 4.7 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtConfigurationCollection.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2007 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 /******************************************************************************
6 ** $RCSfile: DtConfigurationCollection.h,v $ $Revision: 1.11 $ $State: Exp $
7 ******************************************************************************/
8 
12 
13 #ifndef DtConfigurationCollection_H_
14 #define DtConfigurationCollection_H_
15 
16 #include <vector>
17 #include <boost/serialization/split_member.hpp>
18 #include <boost/serialization/set.hpp>
19 
20 namespace makVrv
21 {
23  template <typename ConfigurationType>
25  {
26  public:
27  typedef std::set<ConfigurationType*> Configurations;
28  //typedef ConfigurationType ConfigurationType;
29  typedef typename Configurations::iterator iterator;
30  typedef typename Configurations::const_iterator const_iterator;
31 
33  {
34  }
35 
38  {
40  }
41 
43  {
44  if(this == &copy) return *this;
45  destroyAll();
47  return *this;
48  }
49 
51  {
52  destroyAll();
53  }
54 
55 
56  friend class boost::serialization::access;
60 
61  template<class Archive>
62  void serialize(Archive & ar, const unsigned int version)
63  {
65  }
66 
67 
69  virtual ConfigurationType& add(const ConfigurationType& orig)
70  {
71  typename Configurations::iterator curIter = myConfigurations.begin();
72  typename Configurations::iterator endIter = myConfigurations.end();
73  for(;curIter != endIter;++curIter)
74  {
75  if((*curIter)->name() == orig.name())
76  {
77  DtTHROW_NEW(DtInvalidInput,"A configuration with that name"
78  "already exists in the collection.");
79  }
80  }
81 
82  ConfigurationType* newConfig = new ConfigurationType(orig);
83  myConfigurations.insert( newConfig );
84  return *newConfig;
85  }
86 
100  virtual void destroyConfiguration(ConfigurationType* config)
101  {
102  typename Configurations::iterator iter = myConfigurations.find(config);
103  if(iter == myConfigurations.end())
104  {
105  return;
106  }
107 
108  myConfigurations.erase(iter);
109  delete config;
110  }
111 
112  size_t size() const { return myConfigurations.size(); }
113 
114  iterator begin() { return myConfigurations.begin(); }
115  const_iterator begin() const { return myConfigurations.begin(); }
116 
117  iterator end() { return myConfigurations.end(); }
118  const_iterator end() const { return myConfigurations.end(); }
119 
120 
123  {
124  return myConfigurations;
125  }
126 
128  void addConfigurations(const Configurations& configs)
129  {
130  typename Configurations::const_iterator curIter = configs.begin();
131  typename Configurations::const_iterator endIter = configs.end();
132  for(;curIter != endIter;++curIter)
133  {
134  add(**curIter);
135  }
136  }
137 
139  void destroyAll()
140  {
141  typename Configurations::iterator curIter = myConfigurations.begin();
142  typename Configurations::iterator endIter = myConfigurations.end();
143  for(;curIter != endIter;++curIter)
144  {
145  delete *curIter;
146  }
147  myConfigurations.clear();
148  }
149 
152  virtual ConfigurationType* findConfiguration(const std::string& name)
153  {
154  typename Configurations::iterator curIter = myConfigurations.begin();
155  typename Configurations::iterator endIter = myConfigurations.end();
156  for(;curIter != endIter;++curIter)
157  {
158  if((*curIter)->name() == name)
159  {
160  return (*curIter);
161  }
162  }
163  return 0;
164  }
165 
168  virtual const ConfigurationType* findConfiguration(const std::string& name) const
169  {
170  typename Configurations::const_iterator curIter = myConfigurations.begin();
171  typename Configurations::const_iterator endIter = myConfigurations.end();
172  for(;curIter != endIter;++curIter)
173  {
174  if((*curIter)->name() == name)
175  {
176  return (*curIter);
177  }
178  }
179  return 0;
180  }
181 
182  protected:
183 
185 
186  };
187 }
188 
189 #endif
190 

Document ID: Generated on Fri Apr 26 21:53:14 EDT 2019 from SVN revision 197883
Copyright © 2005-2019 VT MAK. All Rights Reserved (www.mak.com)