ConstraintImplementationFactory.h
Go to the documentation of this file.
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 
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>>
68 };
69 
70 }; // Physics
71 }; // SurgSim
72 
73 #endif
ConstraintType.h
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Physics::ConstraintImplementationFactory::getImplementation
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:87
SurgSim::Physics::ConstraintImplementationFactory::~ConstraintImplementationFactory
~ConstraintImplementationFactory()
Destructor.
Definition: ConstraintImplementationFactory.cpp:83
SurgSim::Physics::ConstraintType
ConstraintType
Definition: ConstraintType.h:24
SurgSim::Physics::ConstraintImplementationFactory::ConstraintImplementationFactory
ConstraintImplementationFactory()
Constructor.
Definition: ConstraintImplementationFactory.cpp:46
SurgSim::Physics::ConstraintImplementationFactory::m_implementations
std::unordered_map< std::type_index, std::array< std::shared_ptr< ConstraintImplementation >, NUM_CONSTRAINT_TYPES > > m_implementations
Lookup table for constraint implementations.
Definition: ConstraintImplementationFactory.h:67
Representation.h
SurgSim::Physics::ConstraintImplementationFactory::addImplementation
void addImplementation(std::type_index typeIndex, std::shared_ptr< ConstraintImplementation > implementation)
Add an implementation to the internal directory.
Definition: ConstraintImplementationFactory.cpp:101
SurgSim::Physics::ConstraintImplementationFactory
This class manages ConstraintImplementations, and can be used to look up the correct implementation b...
Definition: ConstraintImplementationFactory.h:38
SurgSim::Physics::NUM_CONSTRAINT_TYPES
@ NUM_CONSTRAINT_TYPES
Definition: ConstraintType.h:33