Ocean
scenedescription/sdx/x3d/Factory.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_SCENEDESCRIPTION_SDX_X3D_FACTORY_H
9 #define META_OCEAN_SCENEDESCRIPTION_SDX_X3D_FACTORY_H
10 
13 
15 
16 namespace Ocean
17 {
18 
19 namespace SceneDescription
20 {
21 
22 namespace SDX
23 {
24 
25 namespace X3D
26 {
27 
28 /**
29  * This class implements a x3d node factory.
30  * The factory is able to create x3d nodes by their given type names.
31  * @ingroup scenedescriptionsdxx3d
32  */
33 class OCEAN_SCENEDESCRIPTION_SDX_X3D_EXPORT Factory
34 {
35  private:
36 
37  /**
38  * Definition of a function pointer creating nodes.
39  */
40  typedef SDXNodeRef(*CreateNodeFunction)(const SDXNode::SDXEnvironment* environment);
41 
42  /**
43  * Definition of an unordered map mapping names of node types to functions creating the nodes.
44  */
45  typedef std::unordered_map<std::string, CreateNodeFunction> CreateNodeMap;
46 
47  public:
48 
49  /**
50  * Creates a new x3d node by the given type name of the node.
51  * @param type The type name of the x3d node to create, must be valid
52  * @param environment The environment of the node to be created, must be valid
53  */
54  static SDXNodeRef createNode(const std::string& type, const SDXNode::SDXEnvironment* environment);
55 
56  private:
57 
58  /**
59  * Creates a new node with a specific type.
60  * @param environment The environment of the node to be created, must be valid
61  * @tparam T The data type of the node
62  */
63  template <typename T>
64  static SDXNodeRef createNode(const SDXNode::SDXEnvironment* environment);
65 };
66 
67 }
68 
69 }
70 
71 }
72 
73 }
74 
75 #endif // META_OCEAN_SCENEDESCRIPTION_SDX_X3D_FACTORY_H
This class implements a x3d node factory.
Definition: scenedescription/sdx/x3d/Factory.h:34
std::unordered_map< std::string, CreateNodeFunction > CreateNodeMap
Definition of an unordered map mapping names of node types to functions creating the nodes.
Definition: scenedescription/sdx/x3d/Factory.h:45
static SDXNodeRef createNode(const SDXNode::SDXEnvironment *environment)
Creates a new node with a specific type.
static SDXNodeRef createNode(const std::string &type, const SDXNode::SDXEnvironment *environment)
Creates a new x3d node by the given type name of the node.
This class implements a node environment container.
Definition: SDXNode.h:62
This template class implements a smart object reference which is a specialization of an ObjectRef obj...
Definition: SmartObjectRef.h:90
SmartObjectRef< SDXNode, Node > SDXNodeRef
Definition of a smart object reference for SDX scene description nodes.
Definition: SDXNode.h:30
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15