VR-Forces Developer's Guide
 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) 2023 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 <unordered_map>
17 
18 #include <functional>
19 #include <boost/thread/mutex.hpp>
20 
21 namespace makVrv
22 {
23  namespace DynamicTerrain
24  {
26  typedef size_t NodePathHash;
27  }
28 
42  template <typename State>
44  {
45  public:
46 
49 
53 
56 
59  virtual DynamicTerrain::NodePathHash addNodeInstance( const osg::NodePath& nodePath );
60 
63  virtual void setDefaultState( const State& state );
64 
67  virtual const State& defaultState() const;
68 
72  virtual void setState( DynamicTerrain::NodePathHash hashIndex, const State& state );
73 
76  virtual void setState( const State& state );
77 
82  virtual bool getState( DynamicTerrain::NodePathHash hashIndex, State& state );
83 
88  const osg::NodePath& nodePath);
89 
91  typedef std::function<void (DynamicTerrain::NodePathHash)> NodeReferenceFunction;
92 
94  virtual void forEachNodeReference(NodeReferenceFunction& perNodeFunction);
95 
96  private:
100 
101  protected:
102 
103  // Typedef for unordered map used to maintain state indexed by node path hash
104  typedef std::unordered_map<DynamicTerrain::NodePathHash, State> NodeInstanceMap;
105 
106  // The map of node instance states
108 
109  // A list of depths that nodes were added at.
110  std::set<int> myNodePathDepths;
111 
112  // The default state applied to all new references
114 
115  boost::mutex myMapMutex;
116 
117 
118  };
119 }
120 
121 #define DtMultiReferencedNodeContainer_INL_
122 #include "DtMultiReferencedNodeContainer.inl"
123 #undef DtMultiReferencedNodeContainer_INL_
124 
std::unordered_map< DynamicTerrain::NodePathHash, State > NodeInstanceMap
Definition: DtMultiReferencedNodeContainer.h:104
size_t NodePathHash
Typedef used to represent a hash of an OSG Node path to a referenced node.
Definition: DtMultiReferencedNodeContainer.h:26
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:115
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:107
State myDefaultState
Definition: DtMultiReferencedNodeContainer.h:113
virtual const State & defaultState() const
Get the default state used for node references.
std::set< int > myNodePathDepths
Definition: DtMultiReferencedNodeContainer.h:110
Contains DLL export macros.
DtMultiReferencedNodeContainer is a class template that it used to provide support for dynamic nodes ...
Definition: DtMultiReferencedNodeContainer.h:43
std::function< void(DynamicTerrain::NodePathHash)> NodeReferenceFunction
Function type that runs on node reference.
Definition: DtMultiReferencedNodeContainer.h:91

Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)