opensurgsim
ConstraintImplementationFactory.h
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_PHYSICS_CONSTRAINTIMPLEMENTATIONFACTORY_H
17 #define SURGSIM_PHYSICS_CONSTRAINTIMPLEMENTATIONFACTORY_H
18 
19 #include <array>
20 #include <memory>
21 #include <typeindex>
22 #include <unordered_map>
23 
24 #include "SurgSim/Physics/ConstraintType.h"
25 #include "SurgSim/Physics/Representation.h"
26 
27 namespace SurgSim
28 {
29 namespace Physics
30 {
31 
32 class ConstraintImplementation;
33 
39 {
40 public:
41 
44 
47 
53  std::shared_ptr<ConstraintImplementation> getImplementation(
54  std::type_index representationType,
55  ConstraintType constraintType);
56 
60  void addImplementation(std::type_index typeIndex, std::shared_ptr<ConstraintImplementation> implementation);
61 
62 private:
63 
65  std::unordered_map<std::type_index,
66  std::array<std::shared_ptr<ConstraintImplementation>, NUM_CONSTRAINT_TYPES>>
67  m_implementations;
68 };
69 
70 }; // Physics
71 }; // SurgSim
72 
73 #endif
Wraps glewInit() to separate the glew opengl definitions from the osg opengl definitions only imgui n...
Definition: AddRandomSphereBehavior.cpp:36
~ConstraintImplementationFactory()
Destructor.
Definition: ConstraintImplementationFactory.cpp:87
void addImplementation(std::type_index typeIndex, std::shared_ptr< ConstraintImplementation > implementation)
Add an implementation to the internal directory.
Definition: ConstraintImplementationFactory.cpp:105
std::shared_ptr< ConstraintImplementation > getImplementation(std::type_index representationType, ConstraintType constraintType)
Get the instance of a ConstraintImplementation for a specific representation and constraint type...
Definition: ConstraintImplementationFactory.cpp:91
ConstraintImplementationFactory()
Constructor.
Definition: ConstraintImplementationFactory.cpp:47
This class manages ConstraintImplementations, and can be used to look up the correct implementation b...
Definition: ConstraintImplementationFactory.h:38