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, 9> DataGroupCopyMap;
34 
38 {
39 public:
43  DataGroupCopier(const DataGroup& source, DataGroup* target);
44 
50  void copy(const DataGroup& source, DataGroup* target);
51 
52 private:
57  NamedDataCopyMap findMap(std::shared_ptr<const IndexDirectory> source,
58  std::shared_ptr<const IndexDirectory> target) const;
59 
61  DataGroupCopyMap m_map;
62 };
63 
64 }; // namespace DataStructures
65 }; // namespace SurgSim
66 
67 
68 #endif // SURGSIM_DATASTRUCTURES_DATAGROUPCOPIER_H
Definition: CompoundShapeToGraphics.cpp:29
std::array< NamedDataCopyMap, 9 > DataGroupCopyMap
The type used for copying values between two DataGroups that cannot assign to each other...
Definition: DataGroupCopier.h:30
DataGroupCopyMap m_map
The map from source to target.
Definition: DataGroupCopier.h:61
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
NamedDataCopyMap findMap(std::shared_ptr< const IndexDirectory > source, std::shared_ptr< const IndexDirectory > target) const
Find the entries (by name) from the source to target IndexDirectories, and return the matching entrie...
Definition: DataGroupCopier.cpp:56
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:68
A class that assists in copying from one DataGroup to another, when assignment is not possible...
Definition: DataGroupCopier.h:37
void copy(const DataGroup &source, DataGroup *target)
Copies the NamedData entries with the same names.
Definition: DataGroupCopier.cpp:42
DataGroupCopier(const DataGroup &source, DataGroup *target)
Construct a copier.
Definition: DataGroupCopier.cpp:28