OSVR Framework (Internal Development Docs)  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
HandlerContainer.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_HandlerContainer_h_GUID_EAD5E6BA_FEDA_428B_0F12_B30FBE4AD6DB
26 #define INCLUDED_HandlerContainer_h_GUID_EAD5E6BA_FEDA_428B_0F12_B30FBE4AD6DB
27 
28 // Internal Includes
31 
32 // Library/third-party includes
33 // - none
34 
35 // Standard includes
36 #include <vector>
37 
38 namespace osvr {
39 namespace client {
42  public:
43  void update() {
44  for (auto const &handler : m_handlers) {
45  handler->update();
46  }
47  }
48 
49  void add(RemoteHandlerPtr const &handler) {
50  if (!handler) {
51  // Early out for null pointers.
52  return;
53  }
54  m_handlers.insert(handler);
55  }
56 
57  void remove(RemoteHandlerPtr const &handler) {
58  if (!handler) {
59  // Early out for null pointers.
60  return;
61  }
62  m_handlers.remove(handler);
63  }
64 
65  private:
66  typedef std::vector<RemoteHandlerPtr> BaseContainer;
68  typedef util::UniqueContainer<BaseContainer, UniquePolicy,
69  util::container_policies::iterators>
71  InternalHandlerContainer m_handlers;
72  };
73 } // namespace client
74 } // namespace osvr
75 
76 #endif // INCLUDED_HandlerContainer_h_GUID_EAD5E6BA_FEDA_428B_0F12_B30FBE4AD6DB
A basic policy for use with a vector or similar container, where you don't expect a lot of additions ...
Wrapper for a container of handlers.
A "Unique Container" designed for composition, not inheritance.