VR-Forces 4.3.1 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DtSimObjectEntryCollection.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2013 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvCore/vrvCore.h>
13 #include <vrvCore/DtDe.h>
14 #include <vrvCore/DtUniqueID.h>
16 #include <vrvCore/DtDataBank.h>
17 #include <vrvCore/DtStateView.h>
18 #include <boost/bind.hpp>
19 
20 namespace makVrv
21 {
24  template<class T>
26  {
27 
28  public:
29 
31  typedef std::map<DtUniqueID, DtSimObjectEntry*> SimObjectEntryMap;
32 
37 
40 
42  size_t size() const;
43 
45  const SimObjectEntryMap& simObjectEntryMap() const;
46 
49 
51  boost::signal<void (DtSimObjectEntry&)> signal_simObjectEntryAdded;
52 
54  boost::signal<void (DtSimObjectEntry&)> signal_simObjectEntryAboutToBeRemoved;
55 
56  protected:
57 
60 
63 
66 
69 
71  bool isCompatible(DtSimObjectEntry& entry);
72 
74  bool isCompatible(DtSimState& entry);
75 
78 
79  private:
84 
85  protected:
86 
89 
90  };
91 
92  template<class T>
94  : myDe(de)
95  , mySimObjectEntryMap()
96  {
100 
103 
107 
110 
112  }
113 
114  template<class T>
116  {
118  myDe.dataBank().simData().signal_simObjectEntryAdded.disconnect(boost::bind(
120 
121  myDe.dataBank().simData().signal_simObjectEntryToBeRemoved.disconnect(boost::bind(
123 
125  myDe.dataBank().simData().signal_simStateAdded.disconnect(boost::bind(
127 
128  myDe.dataBank().simData().signal_simStateToBeRemoved.disconnect(boost::bind(
130  }
131 
132  template<class T>
134  {
135  if(isCompatible(entry))
136  {
138  onSimObjectEntryAboutToBeRemoved(entry);
139 
141  mySimObjectEntryMap[ entry.id() ] = &entry;
142  signal_simObjectEntryAdded(entry);
143  }
144  }
145 
146  template<class T>
148  {
149  if(isCompatible(state))
150  {
152  onSimObjectStateEntryAboutToBeRemoved(entry, state);
153 
155  mySimObjectEntryMap[ entry.id() ] = &entry;
156  signal_simObjectEntryAdded(entry);
157  }
158  }
159 
160  template<class T>
162  {
163  if(isCompatible(entry))
164  {
165  SimObjectEntryMap::iterator iter = mySimObjectEntryMap.find(entry.id());
166  if(iter != mySimObjectEntryMap.end())
167  {
168  signal_simObjectEntryAboutToBeRemoved(entry);
169  mySimObjectEntryMap.erase(iter);
170  }
171  }
172  }
173 
174  template<class T>
176  {
177  if(isCompatible(state))
178  {
179  SimObjectEntryMap::iterator iter = mySimObjectEntryMap.find(entry.id());
180  if(iter != mySimObjectEntryMap.end())
181  {
182  signal_simObjectEntryAboutToBeRemoved(entry);
183  mySimObjectEntryMap.erase(iter);
184  }
185  }
186  }
187 
188  template<class T>
190  {
191  return DtStateView<T>::isCompatible(entry);
192  }
193 
194  template<class T>
196  {
197  return DtStateView<T>::isCompatible(state);
198  }
199 
200  template<class T>
202  {
203  return mySimObjectEntryMap.size();
204  }
205 
206  template<class T>
208  {
209  DtSimData::SimEntryMap::const_iterator pos;
210  for(pos=myDe.dataBank().simData().simEntryMap().begin(); pos !=
211  myDe.dataBank().simData().simEntryMap().end(); ++pos )
212  {
213  DtSimObjectEntry* pEntry = 0;
214  if(pEntry = dynamic_cast<DtSimObjectEntry*>(pos->second))
215  {
216  onSimObjectEntryAdded(*pEntry);
217  }
218  }
219  }
220 
221  template<class T>
224  {
225  return mySimObjectEntryMap;
226  }
227 
228  template<class T>
230  DtUniqueID id) const
231  {
232  DtSimObjectEntry* entry = 0;
233  SimObjectEntryMap::const_iterator iter = mySimObjectEntryMap.find(id);
234  if(iter != mySimObjectEntryMap.end())
235  {
236  entry = iter->second;
237  }
238  return entry;
239  }
240 }

Document ID: Generated on Wed Jul 29 00:55:00 EDT 2015 from SVN revision 155257
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)