OSVR-Core
RegisteredStringMap.h
Go to the documentation of this file.
1 
11 // Copyright 2015 Sensics, Inc.
12 //
13 // Licensed under the Apache License, Version 2.0 (the "License");
14 // you may not use this file except in compliance with the License.
15 // You may obtain a copy of the License at
16 //
17 // http://www.apache.org/licenses/LICENSE-2.0
18 //
19 // Unless required by applicable law or agreed to in writing, software
20 // distributed under the License is distributed on an "AS IS" BASIS,
21 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 // See the License for the specific language governing permissions and
23 // limitations under the License.
24 
25 #ifndef INCLUDED_RegisteredStringMap_h_GUID_066235BE_3687_44AD_C2A4_593D6E6780F3
26 #define INCLUDED_RegisteredStringMap_h_GUID_066235BE_3687_44AD_C2A4_593D6E6780F3
27 
28 // Internal Includes
29 #include <osvr/Common/Export.h>
30 #include <osvr/Util/StringIds.h>
31 
32 // Library/third-party includes
33 #include <json/value.h>
34 
35 // Standard includes
36 #include <vector>
37 
38 namespace osvr {
39 namespace common {
40 
44  public:
47  OSVR_COMMON_EXPORT util::StringID
48  registerStringID(std::string const &str);
49 
52  OSVR_COMMON_EXPORT util::StringID
53  getStringID(std::string const &str) const;
54 
57  OSVR_COMMON_EXPORT std::string getStringFromId(util::StringID id) const;
58 
60  OSVR_COMMON_EXPORT bool isModified() const;
62  OSVR_COMMON_EXPORT void clearModifiedFlag();
63 
64  OSVR_COMMON_EXPORT void printCurrentMap();
65 
66  OSVR_COMMON_EXPORT std::vector<std::string> getEntries() const;
67 
68  protected:
69  std::vector<std::string> m_regEntries;
70 
72  bool m_modified = false;
73  };
74 
80  public:
83  OSVR_COMMON_EXPORT util::StringID
84  registerStringID(std::string const &str);
85 
88  OSVR_COMMON_EXPORT util::StringID getStringID(std::string const &str) const;
89 
92  OSVR_COMMON_EXPORT std::string getStringFromId(util::StringID id) const;
93 
96  OSVR_COMMON_EXPORT util::StringID
97  convertPeerToLocalID(util::PeerStringID peerID) const;
98 
100  OSVR_COMMON_EXPORT void
101  setupPeerMappings(std::vector<std::string> const &peerEntries);
102 
103  private:
104  RegisteredStringMap m_local;
106  std::vector<uint32_t> m_remoteToLocal;
107  };
108 } // namespace common
109 } // namespace osvr
110 #endif // INCLUDED_RegisteredStringMap_h_GUID_066235BE_3687_44AD_C2A4_593D6E6780F3
OSVR_COMMON_EXPORT bool isModified() const
Has a new entry been added since the flag was last cleared?
Definition: RegisteredStringMap.cpp:89
Handles spatial transformations.
Definition: SerializationTraitExample_Complicated.h:40
OSVR_COMMON_EXPORT util::StringID getStringID(std::string const &str) const
retrieve the StringID associated with the given string returns an empty util::StringID if it was not ...
Definition: RegisteredStringMap.cpp:66
Centralize a string registry.
Definition: RegisteredStringMap.h:43
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
OSVR_COMMON_EXPORT void clearModifiedFlag()
Clear the modified flag.
Definition: RegisteredStringMap.cpp:90
OSVR_COMMON_EXPORT void printCurrentMap()
helper function to print size and contents of the map
Definition: RegisteredStringMap.cpp:39
Definition: TypeSafeId.h:41
This is like a RegisteredStringMap, except it also knows that some peer also has a string map...
Definition: RegisteredStringMap.h:79
bool m_modified
special flag that gets switched whenever new element is inserted;
Definition: RegisteredStringMap.h:72
OSVR_COMMON_EXPORT std::string getStringFromId(util::StringID id) const
retrieve the name of the string given the ID returns empty string if nothing found ...
Definition: RegisteredStringMap.cpp:77
OSVR_COMMON_EXPORT util::StringID registerStringID(std::string const &str)
register new ID with given string and returns StringID.
Definition: RegisteredStringMap.cpp:50
Header.