Fawkes API
Fawkes Development Version
EclipseDebuggerInterface.cpp
1
2
/***************************************************************************
3
* EclipseDebuggerInterface.cpp - Fawkes BlackBoard Interface - EclipseDebuggerInterface
4
*
5
* Templated created: Thu Oct 12 10:49:19 2006
6
* Copyright 2012 Gesche Gierse
7
*
8
****************************************************************************/
9
10
/* This program is free software; you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation; either version 2 of the License, or
13
* (at your option) any later version. A runtime exception applies to
14
* this software (see LICENSE.GPL_WRE file mentioned below for details).
15
*
16
* This program is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
* GNU Library General Public License for more details.
20
*
21
* Read the full text in the LICENSE.GPL_WRE file in the doc directory.
22
*/
23
24
#include <interfaces/EclipseDebuggerInterface.h>
25
26
#include <core/exceptions/software.h>
27
28
#include <map>
29
#include <string>
30
#include <cstring>
31
#include <cstdlib>
32
33
namespace
fawkes
{
34
35
/** @class EclipseDebuggerInterface <interfaces/EclipseDebuggerInterface.h>
36
* EclipseDebuggerInterface Fawkes BlackBoard Interface.
37
* Interface to enable connection between tktools and readylog agent.
38
* @ingroup FawkesInterfaces
39
*/
40
41
42
43
/** Constructor */
44
EclipseDebuggerInterface::EclipseDebuggerInterface() : Interface()
45
{
46
data_size
=
sizeof
(EclipseDebuggerInterface_data_t);
47
data_ptr
= malloc(
data_size
);
48
data = (EclipseDebuggerInterface_data_t *)
data_ptr
;
49
data_ts
= (interface_data_ts_t *)
data_ptr
;
50
memset(
data_ptr
, 0,
data_size
);
51
add_fieldinfo
(
IFT_UINT16
,
"port"
, 1, &data->port);
52
add_fieldinfo
(
IFT_STRING
,
"host"
, 100, data->host);
53
add_messageinfo
(
"ConnectionMessage"
);
54
unsigned
char
tmp_hash[] = {0xc0, 0x8f, 0x5b, 0xb4, 0xcd, 0xf, 0xe0, 0x88, 0xfd, 0x5d, 0xe4, 0xfe, 0x1, 0xb, 0xa2, 0x83};
55
set_hash
(tmp_hash);
56
}
57
58
/** Destructor */
59
EclipseDebuggerInterface::~EclipseDebuggerInterface()
60
{
61
free(
data_ptr
);
62
}
63
/* Methods */
64
/** Get port value.
65
* Port where to connect to
66
* @return port value
67
*/
68
uint16_t
69
EclipseDebuggerInterface::port
()
const
70
{
71
return
data->port;
72
}
73
74
/** Get maximum length of port value.
75
* @return length of port value, can be length of the array or number of
76
* maximum number of characters for a string
77
*/
78
size_t
79
EclipseDebuggerInterface::maxlenof_port
()
const
80
{
81
return
1;
82
}
83
84
/** Set port value.
85
* Port where to connect to
86
* @param new_port new port value
87
*/
88
void
89
EclipseDebuggerInterface::set_port
(
const
uint16_t new_port)
90
{
91
data->port = new_port;
92
data_changed
=
true
;
93
}
94
95
/** Get host value.
96
* Host where to connect to
97
* @return host value
98
*/
99
char
*
100
EclipseDebuggerInterface::host
()
const
101
{
102
return
data->host;
103
}
104
105
/** Get maximum length of host value.
106
* @return length of host value, can be length of the array or number of
107
* maximum number of characters for a string
108
*/
109
size_t
110
EclipseDebuggerInterface::maxlenof_host
()
const
111
{
112
return
100;
113
}
114
115
/** Set host value.
116
* Host where to connect to
117
* @param new_host new host value
118
*/
119
void
120
EclipseDebuggerInterface::set_host
(
const
char
* new_host)
121
{
122
strncpy(data->host, new_host,
sizeof
(data->host)-1);
123
data->host[
sizeof
(data->host)-1] = 0;
124
data_changed
=
true
;
125
}
126
127
/* =========== message create =========== */
128
Message
*
129
EclipseDebuggerInterface::create_message
(
const
char
*
type
)
const
130
{
131
if
( strncmp(
"ConnectionMessage"
,
type
, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
132
return
new
ConnectionMessage
();
133
}
else
{
134
throw
UnknownTypeException
(
"The given type '%s' does not match any known "
135
"message type for this interface type."
,
type
);
136
}
137
}
138
139
140
/** Copy values from other interface.
141
* @param other other interface to copy values from
142
*/
143
void
144
EclipseDebuggerInterface::copy_values
(
const
Interface
*other)
145
{
146
const
EclipseDebuggerInterface *oi =
dynamic_cast<
const
EclipseDebuggerInterface *
>
(other);
147
if
(oi == NULL) {
148
throw
TypeMismatchException(
"Can only copy values from interface of same type (%s vs. %s)"
,
149
type
(), other->type());
150
}
151
memcpy(data, oi->data,
sizeof
(EclipseDebuggerInterface_data_t));
152
}
153
154
const
char
*
155
EclipseDebuggerInterface::enum_tostring
(
const
char
*enumtype,
int
val)
const
156
{
157
throw
UnknownTypeException(
"Unknown enum type %s"
, enumtype);
158
}
159
160
/* =========== messages =========== */
161
/** @class EclipseDebuggerInterface::ConnectionMessage <interfaces/EclipseDebuggerInterface.h>
162
* ConnectionMessage Fawkes BlackBoard Interface Message.
163
*
164
165
*/
166
167
168
/** Constructor */
169
EclipseDebuggerInterface::ConnectionMessage::ConnectionMessage
() :
Message
(
"ConnectionMessage"
)
170
{
171
data_size
=
sizeof
(ConnectionMessage_data_t);
172
data_ptr
= malloc(
data_size
);
173
memset(
data_ptr
, 0,
data_size
);
174
data = (ConnectionMessage_data_t *)
data_ptr
;
175
data_ts
= (
message_data_ts_t
*)
data_ptr
;
176
}
177
178
/** Destructor */
179
EclipseDebuggerInterface::ConnectionMessage::~ConnectionMessage
()
180
{
181
free(
data_ptr
);
182
}
183
184
/** Copy constructor.
185
* @param m message to copy from
186
*/
187
EclipseDebuggerInterface::ConnectionMessage::ConnectionMessage
(
const
ConnectionMessage
*m) :
Message
(m)
188
{
189
data_size
= m->
data_size
;
190
data_ptr
= malloc(
data_size
);
191
memcpy(
data_ptr
, m->
data_ptr
,
data_size
);
192
data = (ConnectionMessage_data_t *)
data_ptr
;
193
data_ts
= (
message_data_ts_t
*)
data_ptr
;
194
}
195
196
/* Methods */
197
/** Clone this message.
198
* Produces a message of the same type as this message and copies the
199
* data to the new message.
200
* @return clone of this message
201
*/
202
Message
*
203
EclipseDebuggerInterface::ConnectionMessage::clone
()
const
204
{
205
return
new
EclipseDebuggerInterface::ConnectionMessage
(
this
);
206
}
207
/** Check if message is valid and can be enqueued.
208
* @param message Message to check
209
* @return true if the message is valid, false otherwise.
210
*/
211
bool
212
EclipseDebuggerInterface::message_valid
(
const
Message
*message)
const
213
{
214
const
ConnectionMessage
*m0 =
dynamic_cast<
const
ConnectionMessage
*
>
(message);
215
if
( m0 != NULL ) {
216
return
true
;
217
}
218
return
false
;
219
}
220
221
/// @cond INTERNALS
222
EXPORT_INTERFACE(
EclipseDebuggerInterface
)
223
/// @endcond
224
225
226
}
// end namespace fawkes
fawkes::Interface::data_ptr
void * data_ptr
Definition:
interface.h:224
fawkes::EclipseDebuggerInterface::copy_values
virtual void copy_values(const Interface *other)
Copy values from other interface.
Definition:
EclipseDebuggerInterface.cpp:150
fawkes::EclipseDebuggerInterface::maxlenof_host
size_t maxlenof_host() const
Get maximum length of host value.
Definition:
EclipseDebuggerInterface.cpp:116
fawkes::Message
Definition:
message.h:41
fawkes::Message::data_ptr
void * data_ptr
Definition:
message.h:125
fawkes::Message::data_ts
message_data_ts_t * data_ts
data timestamp aliasing pointer
Definition:
message.h:135
fawkes::IFT_UINT16
@ IFT_UINT16
16 bit unsigned integer field
Definition:
types.h:55
fawkes::Interface::type
const char * type() const
Get type of interface.
Definition:
interface.cpp:645
fawkes::EclipseDebuggerInterface::ConnectionMessage::ConnectionMessage
ConnectionMessage()
Constructor.
Definition:
EclipseDebuggerInterface.cpp:175
fawkes::Interface::data_ts
interface_data_ts_t * data_ts
Definition:
interface.h:228
fawkes::EclipseDebuggerInterface::maxlenof_port
size_t maxlenof_port() const
Get maximum length of port value.
Definition:
EclipseDebuggerInterface.cpp:85
fawkes::EclipseDebuggerInterface::ConnectionMessage::~ConnectionMessage
~ConnectionMessage()
Destructor.
Definition:
EclipseDebuggerInterface.cpp:185
fawkes::EclipseDebuggerInterface::port
uint16_t port() const
Get port value.
Definition:
EclipseDebuggerInterface.cpp:75
fawkes::EclipseDebuggerInterface::set_host
void set_host(const char *new_host)
Set host value.
Definition:
EclipseDebuggerInterface.cpp:126
fawkes::Message::message_data_ts_t
Timestamp data, must be present and first entries for each interface data structs!...
Definition:
message.h:130
fawkes::Interface::data_changed
bool data_changed
Definition:
interface.h:226
fawkes::UnknownTypeException
Definition:
software.h:55
fawkes::Interface::Interface
Interface()
Constructor.
Definition:
interface.cpp:238
fawkes
fawkes::Interface::set_hash
void set_hash(unsigned char *ihash)
Set hash.
Definition:
interface.cpp:321
fawkes::Message::data_size
unsigned int data_size
Definition:
message.h:126
fawkes::EclipseDebuggerInterface
Definition:
EclipseDebuggerInterface.h:39
fawkes::EclipseDebuggerInterface::host
char * host() const
Get host value.
Definition:
EclipseDebuggerInterface.cpp:106
fawkes::EclipseDebuggerInterface::set_port
void set_port(const uint16_t new_port)
Set port value.
Definition:
EclipseDebuggerInterface.cpp:95
fawkes::Message::add_fieldinfo
void add_fieldinfo(interface_fieldtype_t type, const char *name, size_t length, void *value, const char *enumtype=0, const interface_enum_map_t *enum_map=0)
Add an entry to the info list.
Definition:
message.cpp:406
fawkes::Interface::data_size
unsigned int data_size
Definition:
interface.h:225
fawkes::EclipseDebuggerInterface::create_message
virtual Message * create_message(const char *type) const
Definition:
EclipseDebuggerInterface.cpp:135
fawkes::EclipseDebuggerInterface::message_valid
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
Definition:
EclipseDebuggerInterface.cpp:218
fawkes::IFT_STRING
@ IFT_STRING
string field
Definition:
types.h:62
fawkes::EclipseDebuggerInterface::ConnectionMessage
Definition:
EclipseDebuggerInterface.h:66
fawkes::Interface::add_messageinfo
void add_messageinfo(const char *name)
Add an entry to the message info list.
Definition:
interface.cpp:380
fawkes::EclipseDebuggerInterface::ConnectionMessage::clone
virtual Message * clone() const
Clone this message.
Definition:
EclipseDebuggerInterface.cpp:209
fawkes::EclipseDebuggerInterface::enum_tostring
virtual const char * enum_tostring(const char *enumtype, int val) const
Definition:
EclipseDebuggerInterface.cpp:161
src
libs
interfaces
EclipseDebuggerInterface.cpp
Generated by
1.8.17