DataGroupCopier.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2012-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_DATASTRUCTURES_DATAGROUPCOPIER_H
17 #define SURGSIM_DATASTRUCTURES_DATAGROUPCOPIER_H
18 
19 #include <array>
20 #include <memory>
21 #include <unordered_map>
22 
24 
25 namespace SurgSim
26 {
27 namespace DataStructures
28 {
29 class DataGroup;
31 
33 typedef std::array<NamedDataCopyMap, 8> DataGroupCopyMap;
34 
38 {
39 public:
43  DataGroupCopier(const DataGroup& source, DataGroup& target);
44 
46  void copy();
47 
48 private:
50  void findMap();
51 
56  NamedDataCopyMap findMap(std::shared_ptr<const IndexDirectory> source,
57  std::shared_ptr<const IndexDirectory> target) const;
58 
61 
64 
66  DataGroupCopyMap m_map;
67 };
68 
69 }; // namespace DataStructures
70 }; // namespace SurgSim
71 
72 
73 #endif // SURGSIM_DATASTRUCTURES_DATAGROUPCOPIER_H
Definition: DriveElementFromInputBehavior.cpp:27
DataGroupCopyMap m_map
The map from source to target.
Definition: DataGroupCopier.h:66
std::array< NamedDataCopyMap, 8 > DataGroupCopyMap
The type used for copying values between two DataGroups that cannot assign to each other...
Definition: DataGroupCopier.h:30
const DataGroup & m_source
The source DataGroup.
Definition: DataGroupCopier.h:60
DataGroupCopier(const DataGroup &source, DataGroup &target)
Construct a copier.
Definition: DataGroupCopier.cpp:28
void findMap()
Find the entries (by name) from the source to target DataGroups.
Definition: DataGroupCopier.cpp:47
std::unordered_map< int, int > NamedDataCopyMap
The type used for copying values between two NamedData objects that cannot assign to each other...
Definition: NamedData.h:32
void copy()
Copies the NamedData entries with the same names. Resets entries in the target that are reset in the ...
Definition: DataGroupCopier.cpp:35
A simple bidirectional mapping between names (strings) and distinct consecutive non-negative indices...
Definition: IndexDirectory.h:32
A collection of NamedData objects.
Definition: DataGroup.h:66
A class that assists in copying from one DataGroup to another, when assignment is not possible...
Definition: DataGroupCopier.h:37
DataGroup & m_target
The target DataGroup.
Definition: DataGroupCopier.h:63