8
<rpavlik@iastate.edu> and <abiryan@ryand.net>
9
http://academic.cleardefinition.com/
10
Iowa State University Virtual Reality Applications Center
11
Human-Computer Interaction Graduate Program
14
// Copyright Iowa State University 2011.
15
// Distributed under the Boost Software License, Version 1.0.
16
// (See accompanying file LICENSE_1_0.txt or copy at
17
// http://www.boost.org/LICENSE_1_0.txt)
20
#ifndef INCLUDED_vrpn_MainloopContainer_h_GUID_2146c66c_1925_4ac3_a192_354d10d7a39f
21
#define INCLUDED_vrpn_MainloopContainer_h_GUID_2146c66c_1925_4ac3_a192_354d10d7a39f
24
#include "vrpn_MainloopObject.h"
26
// Library/third-party includes
32
/// A container that holds and owns one or more VRPN objects,
33
class vrpn_MainloopContainer {
36
vrpn_MainloopContainer() {}
37
/// Destructor: invokes clear()
38
~vrpn_MainloopContainer();
40
/// Clear internal structure holding objects, deleting them
41
/// in reverse order of their addition.
44
/// Add an object wrapped by vrpn_MainloopObject.
45
void add(vrpn_MainloopObject * o);
47
/// Template method to automatically wrap objects
48
/// with vrpn_MainloopObject before adding them.
51
add(vrpn_MainloopObject::wrap(o));
54
/// Runs mainloop on all contained objects, in the order
55
/// that they were added.
59
std::vector<vrpn_MainloopObject *> _vrpn;
62
/* -- inline implementations -- */
64
inline vrpn_MainloopContainer::~vrpn_MainloopContainer() {
68
inline void vrpn_MainloopContainer::add(vrpn_MainloopObject* o) {
75
inline void vrpn_MainloopContainer::clear() {
79
/// Delete in reverse order
80
for (size_t i = _vrpn.size() - 1; i >= 0; --i) {
87
inline void vrpn_MainloopContainer::mainloop() {
88
const size_t n = _vrpn.size();
89
for (size_t i = 0; i < n; ++i) {
94
#endif // INCLUDED_vrpn_MainloopContainer_h_GUID_2146c66c_1925_4ac3_a192_354d10d7a39f