VR-Forces 4.6 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties 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  {
97  DtSimData& simDataObj = myDe.dataBank().simData();
98 
100  simDataObj.signal_simObjectEntryAdded.connect(boost::bind(
102 
105 
107  simDataObj.signal_simStateAdded.connect(boost::bind(
109 
110  simDataObj.signal_simStateToBeRemoved.connect(boost::bind(
112 
114  }
115 
116  template<class T>
118  {
119  DtSimData& simDataObj = myDe.dataBank().simData();
120 
122  simDataObj.signal_simObjectEntryAdded.disconnect(boost::bind(
124 
125  simDataObj.signal_simObjectEntryToBeRemoved.disconnect(boost::bind(
127 
129  simDataObj.signal_simStateAdded.disconnect(boost::bind(
131 
132  simDataObj.signal_simStateToBeRemoved.disconnect(boost::bind(
134  }
135 
136  template<class T>
138  {
139  if(isCompatible(entry))
140  {
142  onSimObjectEntryAboutToBeRemoved(entry);
143 
145  mySimObjectEntryMap[ entry.id() ] = &entry;
146  signal_simObjectEntryAdded(entry);
147  }
148  }
149 
150  template<class T>
152  {
153  if(isCompatible(state))
154  {
156  onSimObjectStateEntryAboutToBeRemoved(entry, state);
157 
159  mySimObjectEntryMap[ entry.id() ] = &entry;
160  signal_simObjectEntryAdded(entry);
161  }
162  }
163 
164  template<class T>
166  {
167  if(isCompatible(entry))
168  {
169  SimObjectEntryMap::iterator iter = mySimObjectEntryMap.find(entry.id());
170  if(iter != mySimObjectEntryMap.end())
171  {
172  signal_simObjectEntryAboutToBeRemoved(entry);
173  mySimObjectEntryMap.erase(iter);
174  }
175  }
176  }
177 
178  template<class T>
180  {
181  if(isCompatible(state))
182  {
183  SimObjectEntryMap::iterator iter = mySimObjectEntryMap.find(entry.id());
184  if(iter != mySimObjectEntryMap.end())
185  {
186  signal_simObjectEntryAboutToBeRemoved(entry);
187  mySimObjectEntryMap.erase(iter);
188  }
189  }
190  }
191 
192  template<class T>
194  {
195  return DtStateView<T>::isCompatible(entry);
196  }
197 
198  template<class T>
200  {
201  return DtStateView<T>::isCompatible(state);
202  }
203 
204  template<class T>
206  {
207  return mySimObjectEntryMap.size();
208  }
209 
210  template<class T>
212  {
213  DtSimData::SimEntryMap::const_iterator pos;
214  for(pos=myDe.dataBank().simData().simEntryMap().begin(); pos !=
215  myDe.dataBank().simData().simEntryMap().end(); ++pos )
216  {
217  DtSimObjectEntry* pEntry = dynamic_cast<DtSimObjectEntry*>(pos->second);
218  if(pEntry)
219  {
220  onSimObjectEntryAdded(*pEntry);
221  }
222  }
223  }
224 
225  template<class T>
228  {
229  return mySimObjectEntryMap;
230  }
231 
232  template<class T>
234  DtUniqueID id) const
235  {
236  DtSimObjectEntry* entry = 0;
237  SimObjectEntryMap::const_iterator iter = mySimObjectEntryMap.find(id);
238  if(iter != mySimObjectEntryMap.end())
239  {
240  entry = iter->second;
241  }
242  return entry;
243  }
244 }

Document ID: Generated on Thu Apr 12 03:15:37 EDT 2018 from SVN revision 187986
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)