VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtMultiReferencedNodeContainer.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2018 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvOsg/vrvOsg.h>
13 
14 #include <osg/Node>
15 
16 #include <boost/unordered_map.hpp>
17 #include <boost/function.hpp>
18 #include <boost/thread/mutex.hpp>
19 
20 namespace makVrv
21 {
22  namespace DynamicTerrain
23  {
25  typedef size_t NodePathHash;
26  }
27 
41  template <typename State>
43  {
44  public:
45 
48 
52 
55 
58  virtual DynamicTerrain::NodePathHash addNodeInstance( const osg::NodePath& nodePath );
59 
62  virtual void setDefaultState( const State& state );
63 
66  virtual const State& defaultState() const;
67 
71  virtual void setState( DynamicTerrain::NodePathHash hashIndex, const State& state );
72 
75  virtual void setState( const State& state );
76 
81  virtual bool getState( DynamicTerrain::NodePathHash hashIndex, State& state );
82 
87  const osg::NodePath& nodePath);
88 
90  typedef boost::function<void (DynamicTerrain::NodePathHash)> NodeReferenceFunction;
91 
93  virtual void forEachNodeReference(NodeReferenceFunction& perNodeFunction);
94 
95  private:
99 
100  protected:
101 
102  // Typedef for unordered map used to maintain state indexed by node path hash
103  typedef boost::unordered_map<DynamicTerrain::NodePathHash, State> NodeInstanceMap;
104 
105  // The map of node instance states
107 
108  // A list of depths that nodes were added at.
109  std::set<int> myNodePathDepths;
110 
111  // The default state applied to all new references
113 
114  boost::mutex myMapMutex;
115 
116 
117  };
118 }
119 
120 #define DtMultiReferencedNodeContainer_INL_
121 #include "DtMultiReferencedNodeContainer.inl"
122 #undef DtMultiReferencedNodeContainer_INL_
123 
boost::unordered_map< DynamicTerrain::NodePathHash, State > NodeInstanceMap
Definition: DtMultiReferencedNodeContainer.h:103
size_t NodePathHash
Typedef used to represent a hash of an OSG Node path to a referenced node.
Definition: DtMultiReferencedNodeContainer.h:25
virtual DynamicTerrain::NodePathHash addNodeInstance(const osg::NodePath &nodePath)
Add a reference to a node and return the hash for the passed in node path.
virtual void forEachNodeReference(NodeReferenceFunction &perNodeFunction)
Execute a function on each node reference in the container.
virtual DynamicTerrain::NodePathHash calcNodePathHashValue(const osg::NodePath &nodePath)
Calculate a node hash, checks all known depths that nodes werer added at.
virtual void setDefaultState(const State &state)
Specify a default state used to initialize each node reference when added.
DtMultiReferencedNodeContainer & operator=(const DtMultiReferencedNodeContainer &)
Private assignment operator.
boost::mutex myMapMutex
Definition: DtMultiReferencedNodeContainer.h:114
virtual void setState(DynamicTerrain::NodePathHash hashIndex, const State &state)
Set the state of a node reference.
virtual bool getState(DynamicTerrain::NodePathHash hashIndex, State &state)
Get the state of node instance.
NodeInstanceMap myNodeInstanceMap
Definition: DtMultiReferencedNodeContainer.h:106
State myDefaultState
Definition: DtMultiReferencedNodeContainer.h:112
virtual const State & defaultState() const
Get the default state used for node references.
std::set< int > myNodePathDepths
Definition: DtMultiReferencedNodeContainer.h:109
Contains DLL export macros.
boost::function< void(DynamicTerrain::NodePathHash)> NodeReferenceFunction
Function type that runs on node reference.
Definition: DtMultiReferencedNodeContainer.h:90
DtMultiReferencedNodeContainer is a class template that it used to provide support for dynamic nodes ...
Definition: DtMultiReferencedNodeContainer.h:42

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)