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
33namespace 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 */
44EclipseDebuggerInterface::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 */
59EclipseDebuggerInterface::~EclipseDebuggerInterface()
60{
61 free(data_ptr);
62}
63/* Methods */
64/** Get port value.
65 * Port where to connect to
66 * @return port value
67 */
68uint16_t
69EclipseDebuggerInterface::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 */
78size_t
79EclipseDebuggerInterface::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 */
88void
89EclipseDebuggerInterface::set_port(const uint16_t new_port)
90{
91 set_field(data->port, new_port);
92}
93
94/** Get host value.
95 * Host where to connect to
96 * @return host value
97 */
98char *
99EclipseDebuggerInterface::host() const
100{
101 return data->host;
102}
103
104/** Get maximum length of host value.
105 * @return length of host value, can be length of the array or number of
106 * maximum number of characters for a string
107 */
108size_t
109EclipseDebuggerInterface::maxlenof_host() const
110{
111 return 100;
112}
113
114/** Set host value.
115 * Host where to connect to
116 * @param new_host new host value
117 */
118void
119EclipseDebuggerInterface::set_host(const char * new_host)
120{
121 set_field(data->host, new_host);
122}
123
124/* =========== message create =========== */
125Message *
126EclipseDebuggerInterface::create_message(const char *type) const
127{
128 if ( strncmp("ConnectionMessage", type, INTERFACE_MESSAGE_TYPE_SIZE_ - 1) == 0 ) {
129 return new ConnectionMessage();
130 } else {
131 throw UnknownTypeException("The given type '%s' does not match any known "
132 "message type for this interface type.", type);
133 }
134}
135
136
137/** Copy values from other interface.
138 * @param other other interface to copy values from
139 */
140void
141EclipseDebuggerInterface::copy_values(const Interface *other)
142{
143 const EclipseDebuggerInterface *oi = dynamic_cast<const EclipseDebuggerInterface *>(other);
144 if (oi == NULL) {
145 throw TypeMismatchException("Can only copy values from interface of same type (%s vs. %s)",
146 type(), other->type());
147 }
148 memcpy(data, oi->data, sizeof(EclipseDebuggerInterface_data_t));
149}
150
151const char *
152EclipseDebuggerInterface::enum_tostring(const char *enumtype, int val) const
153{
154 throw UnknownTypeException("Unknown enum type %s", enumtype);
155}
156
157/* =========== messages =========== */
158/** @class EclipseDebuggerInterface::ConnectionMessage <interfaces/EclipseDebuggerInterface.h>
159 * ConnectionMessage Fawkes BlackBoard Interface Message.
160 *
161
162 */
163
164
165/** Constructor */
166EclipseDebuggerInterface::ConnectionMessage::ConnectionMessage() : Message("ConnectionMessage")
167{
168 data_size = sizeof(ConnectionMessage_data_t);
169 data_ptr = malloc(data_size);
170 memset(data_ptr, 0, data_size);
171 data = (ConnectionMessage_data_t *)data_ptr;
173}
174
175/** Destructor */
177{
178 free(data_ptr);
179}
180
181/** Copy constructor.
182 * @param m message to copy from
183 */
185{
186 data_size = m->data_size;
187 data_ptr = malloc(data_size);
188 memcpy(data_ptr, m->data_ptr, data_size);
189 data = (ConnectionMessage_data_t *)data_ptr;
191}
192
193/* Methods */
194/** Clone this message.
195 * Produces a message of the same type as this message and copies the
196 * data to the new message.
197 * @return clone of this message
198 */
199Message *
201{
203}
204/** Check if message is valid and can be enqueued.
205 * @param message Message to check
206 * @return true if the message is valid, false otherwise.
207 */
208bool
210{
211 const ConnectionMessage *m0 = dynamic_cast<const ConnectionMessage *>(message);
212 if ( m0 != NULL ) {
213 return true;
214 }
215 return false;
216}
217
218/// @cond INTERNALS
219EXPORT_INTERFACE(EclipseDebuggerInterface)
220/// @endcond
221
222
223} // end namespace fawkes
ConnectionMessage Fawkes BlackBoard Interface Message.
virtual Message * clone() const
Clone this message.
EclipseDebuggerInterface Fawkes BlackBoard Interface.
virtual bool message_valid(const Message *message) const
Check if message is valid and can be enqueued.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
const char * type() const
Get type of interface.
Definition: interface.cpp:652
void * data_ptr
Pointer to local memory storage.
Definition: interface.h:244
Base class for all messages passed through interfaces in Fawkes BlackBoard.
Definition: message.h:44
void * data_ptr
Pointer to memory that contains local data.
Definition: message.h:146
message_data_ts_t * data_ts
data timestamp aliasing pointer
Definition: message.h:156
unsigned int data_size
Size of memory needed to hold all data.
Definition: message.h:147
Fawkes library namespace.
Timestamp data, must be present and first entries for each interface data structs!...
Definition: message.h:152