forked from OpenDDS/OpenDDS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMonitorData.cpp
209 lines (175 loc) · 4.51 KB
/
MonitorData.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/*
*
*
* Distributed under the OpenDDS License.
* See: http://www.opendds.org/license.html
*/
#include "MonitorData.h"
#include "Options.h"
#include "MonitorTask.h"
#include "MonitorDataModel.h"
#include "MonitorDataStorage.h"
#include "dds/DCPS/Service_Participant.h"
#include "dds/monitor/monitorC.h"
Monitor::MonitorData::MonitorData( const Options& options, MonitorDataModel* model, bool mapExistingIORKeys)
: enabled_( true),
options_( options),
model_( model),
dataSource_( 0),
storage_( new MonitorDataStorage( this))
{
this->dataSource_ = new MonitorTask( this->storage_, this->options_, mapExistingIORKeys);
this->dataSource_->start();
}
Monitor::MonitorData::~MonitorData()
{
this->disable();
delete this->dataSource_;
delete this->storage_;
}
void
Monitor::MonitorData::disable()
{
this->enabled_ = false;
}
void
Monitor::MonitorData::getIorList( QList<QString>& iorList)
{
for( MonitorTask::IorKeyMap::const_iterator
location = this->dataSource_->iorKeyMap().begin();
location != this->dataSource_->iorKeyMap().end();
++location) {
iorList.append( QString( QObject::tr( location->first.c_str())));
}
}
bool
Monitor::MonitorData::setRepoIor( const QString& ior)
{
if( !this->enabled_) {
return false;
}
// Replace call to toStdString() with toLocal8Bit().constData()
// to avoid QString-related aborts under windows.
QByteArray ior_arr = ior.toLocal8Bit();
const char* ior_str = ior_arr.constData();
// Return successfully if the requested repository is already the
// active repository.
if( this->storage_->activeIor() == ior_str) {
return true;
}
// Set the repository IOR.
MonitorTask::RepoKey key
= this->dataSource_->setRepoIor( ior_str);
// Clear existing data.
this->clearData();
// Switch to the new repository.
if( this->dataSource_->setActiveRepo( key)) {
this->storage_->activeIor() = ior_str;
return true;
} else {
return false;
}
}
bool
Monitor::MonitorData::removeRepo( const QString& ior)
{
if( !this->enabled_) {
return false;
}
// Replace call to toStdString() with toLocal8Bit().constData()
// to avoid QString-related aborts under windows.
QByteArray ior_arr = ior.toLocal8Bit();
const char* ior_str = ior_arr.constData();
// Check if this is the currently monitored repository, and clear its
// data if it is in the view.
if( this->storage_->activeIor() == ior_str) {
this->clearData();
}
// Look up the index for this IOR and remove it from the service.
return true;
}
bool
Monitor::MonitorData::clearData()
{
if( !this->enabled_) {
return false;
}
// Copy out the previous header settings.
QList< QVariant> list;
int cols = this->model_->columnCount();
for( int index = 0; index < cols; ++index) {
QString value
= this->model_->headerData( index, Qt::Horizontal).toString();
list << value;
}
// Clear the mappings.
this->storage_->reset();
// Create a new tree to install fresh data into.
TreeNode* root = new TreeNode( list);
// Install the empty tree into the data model.
this->model_->newRoot( root);
// Clear the active IOR field.
this->storage_->activeIor() = std::string();
return true;
}
bool
Monitor::MonitorData::stopInstrumentation()
{
if( !this->enabled_) {
return false;
}
this->dataSource_->stopInstrumentation();
return true;
}
bool
Monitor::MonitorData::getBuiltinTopicData(
const OpenDDS::DCPS::GUID_t& id,
DDS::ParticipantBuiltinTopicData& data
)
{
return this->dataSource_->getBuiltinTopicData( id, data);
}
bool
Monitor::MonitorData::getBuiltinTopicData(
const OpenDDS::DCPS::GUID_t& id,
DDS::TopicBuiltinTopicData& data
)
{
return this->dataSource_->getBuiltinTopicData( id, data);
}
bool
Monitor::MonitorData::getBuiltinTopicData(
const OpenDDS::DCPS::GUID_t& id,
DDS::PublicationBuiltinTopicData& data
)
{
return this->dataSource_->getBuiltinTopicData( id, data);
}
bool
Monitor::MonitorData::getBuiltinTopicData(
const OpenDDS::DCPS::GUID_t& id,
DDS::SubscriptionBuiltinTopicData& data
)
{
return this->dataSource_->getBuiltinTopicData( id, data);
}
Monitor::TreeNode*
Monitor::MonitorData::modelRoot()
{
return this->model_->getNode( QModelIndex());
}
void
Monitor::MonitorData::updated( TreeNode* node, int column)
{
this->model_->updated( node, column);
}
void
Monitor::MonitorData::updated( TreeNode* left, int lcol, TreeNode* right, int rcol)
{
this->model_->updated( left, lcol, right, rcol);
}
void
Monitor::MonitorData::changed()
{
this->model_->changed();
}