VR-Forces 4.1 Class Documentation
DtSimObjectEntryCollection.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2009 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 /******************************************************************************
6 ** $RCSfile: DtSimObjectEntryCollection.h,v $ $Revision: 1.10 $ $State: Exp $
7 ******************************************************************************/
8 
12 
13 #ifndef DtSimObjectEntryCollection_H_
14 #define DtSimObjectEntryCollection_H_
15 
16 #include <vrvCore/vrvCore.h>
17 #include <vrvCore/DtDe.h>
18 #include <vrvCore/DtUniqueID.h>
20 #include <vrvCore/DtDataBank.h>
21 #include <vrvCore/DtStateView.h>
22 #include <boost/bind.hpp>
23 
24 namespace makVrv
25 {
28  template<class T>
30  {
31 
32  public:
33 
35  typedef std::map<DtUniqueID, DtSimObjectEntry*> SimObjectEntryMap;
36 
41 
44 
46  size_t size() const;
47 
49  const SimObjectEntryMap& simObjectEntryMap() const;
50 
53 
55  boost::signal<void (DtSimObjectEntry&)> signal_simObjectEntryAdded;
56 
58  boost::signal<void (DtSimObjectEntry&)> signal_simObjectEntryAboutToBeRemoved;
59 
60  protected:
61 
64 
67 
69  bool isCompatible(DtSimObjectEntry& entry);
70 
73 
74  private:
79 
80  protected:
81 
84 
85  };
86 
87  template<class T>
89  : myDe(de)
90  , mySimObjectEntryMap()
91  {
93  myDe.dataBank().simData().signal_simObjectEntryAdded.connect(boost::bind(
95 
96  myDe.dataBank().simData().signal_simObjectEntryToBeRemoved.connect(boost::bind(
98 
100  myDe.dataBank().simData().signal_simStateAdded.connect(boost::bind(
102 
103  myDe.dataBank().simData().signal_simStateToBeRemoved.connect(boost::bind(
105 
107  }
108 
109  template<class T>
111  {
113  myDe.dataBank().simData().signal_simObjectEntryAdded.disconnect(boost::bind(
115 
116  myDe.dataBank().simData().signal_simObjectEntryToBeRemoved.disconnect(boost::bind(
118 
120  myDe.dataBank().simData().signal_simStateAdded.disconnect(boost::bind(
122 
123  myDe.dataBank().simData().signal_simStateToBeRemoved.disconnect(boost::bind(
125  }
126 
127  template<class T>
129  {
130  if(isCompatible(entry))
131  {
133  onSimObjectEntryAboutToBeRemoved(entry);
134 
136  mySimObjectEntryMap[ entry.id() ] = &entry;
137  signal_simObjectEntryAdded(entry);
138  }
139  }
140 
141  template<class T>
143  {
144  if(isCompatible(entry))
145  {
146  SimObjectEntryMap::iterator iter = mySimObjectEntryMap.find(entry.id());
147  if(iter != mySimObjectEntryMap.end())
148  {
149  signal_simObjectEntryAboutToBeRemoved(entry);
150  mySimObjectEntryMap.erase(iter);
151  }
152  }
153  }
154 
155  template<class T>
157  {
158  return DtStateView<T>::isCompatible(entry);
159  }
160 
161  template<class T>
163  {
164  return mySimObjectEntryMap.size();
165  }
166 
167  template<class T>
169  {
170  DtSimData::SimEntryMap::const_iterator pos;
171  for(pos=myDe.dataBank().simData().simEntryMap().begin(); pos !=
172  myDe.dataBank().simData().simEntryMap().end(); ++pos )
173  {
174  DtSimObjectEntry* pEntry = 0;
175  if(pEntry = dynamic_cast<DtSimObjectEntry*>(pos->second))
176  {
177  onSimObjectEntryAdded(*pEntry);
178  }
179  }
180  }
181 
182  template<class T>
185  {
186  return mySimObjectEntryMap;
187  }
188 
189  template<class T>
191  DtUniqueID id) const
192  {
193  DtSimObjectEntry* entry = 0;
194  SimObjectEntryMap::const_iterator iter = mySimObjectEntryMap.find(id);
195  if(iter != mySimObjectEntryMap.end())
196  {
197  entry = iter->second;
198  }
199  return entry;
200  }
201 }
202 
203 #endif
204 

Document ID: Generated on Tue Jan 29 18:21:16 EST 2013 from SVN revision 123193
Copyright © 2005-2013 VT MÄK Inc. All Rights Reserved (www.mak.com)