RflySimSDK v3.05
RflySimSDK说明文档
载入中...
搜索中...
未找到
vrpn_MainloopContainer.h
浏览该文件的文档.
1
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)
18
19#pragma once
20
21// Internal Includes
22#include "vrpn_MainloopObject.h"
23
24// Library/third-party includes
25// - none
26
29public:
34
37 void clear();
38
43
47 template <class T> T add(T o)
48 {
50 return NULL;
51 }
52 return o;
53 }
54
57 void mainloop();
58
59private:
61};
62
63/* -- inline implementations -- */
64
66
68{
69 // If the object is NULL, we have a problem and don't add it.
70 if (!o) {
71 return o;
72 }
73
74 // If the object is broken(), this indicates a problem
75 // with the device. We also do not add it and we return NULL to show.
76 // that there is a problem.
77 if (o->broken()) {
78 fprintf(
79 stderr,
80 "vrpn_MainloopContainer::add() Device is broken, not adding.\n");
81 return NULL;
82 }
83
84 _vrpn.push_back(o);
85 return o;
86}
87
89{
90 if (_vrpn.empty()) {
91 return;
92 }
94 for (int i = int(_vrpn.size()) - 1; i >= 0; --i) {
95 try {
96 delete _vrpn[i];
97 } catch (...) {
98 fprintf(stderr, "vrpn_MainloopContainer::clear: delete failed\n");
99 return;
100 }
101 _vrpn[i] = NULL;
102 }
103 _vrpn.clear();
104}
105
107{
108 const size_t n = _vrpn.size();
109 for (size_t i = 0; i < n; ++i) {
110 _vrpn[i]->mainloop();
111 }
112}
A container that holds and owns one or more VRPN objects,
定义 vrpn_MainloopContainer.h:28
vrpn_MainloopContainer()
Constructor
定义 vrpn_MainloopContainer.h:31
~vrpn_MainloopContainer()
Destructor: invokes clear()
定义 vrpn_MainloopContainer.h:65
T add(T o)
定义 vrpn_MainloopContainer.h:47
void mainloop()
定义 vrpn_MainloopContainer.h:106
vrpn_MainloopObject * add(vrpn_MainloopObject *o)
定义 vrpn_MainloopContainer.h:67
void clear()
定义 vrpn_MainloopContainer.h:88
定义 vrpn_MainloopObject.h:43
static vrpn_MainloopObject * wrap(T o)
Templated wrapping function
定义 vrpn_MainloopObject.h:176
virtual bool broken()=0
定义 vrpn_Shared.h:552