DISPLACE  1.0
A spatial model of fisheries to help sustainable fishing and maritime spatial planning
outputmessage.h
Go to the documentation of this file.
1 // --------------------------------------------------------------------------
2 // DISPLACE: DYNAMIC INDIVIDUAL VESSEL-BASED SPATIAL PLANNING
3 // AND EFFORT DISPLACEMENT
4 // Copyright (c) 2012-2019 Francois Bastardie <fba@aqua.dtu.dk>
5 
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
10 
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
15 
16 // You should have received a copy of the GNU General Public License along
17 // with this program; if not, write to the Free Software Foundation, Inc.,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 // --------------------------------------------------------------------------
20 
21 /* --------------------------------------------------------------------------
22  * DISPLACE: DYNAMIC INDIVIDUAL VESSEL-BASED SPATIAL PLANNING
23  * AND EFFORT DISPLACEMENT
24  * Copyright (c) 2012, 2013, 2014, 2015 Francois Bastardie <fba@aqua.dtu.dk>
25  *
26  * This program is free software; you can redistribute it and/or modify
27  * it under the terms of the GNU General Public License as published by
28  * the Free Software Foundation; either version 2 of the License, or
29  * (at your option) any later version.
30  *
31  * This program is distributed in the hope that it will be useful,
32  * but WITHOUT ANY WARRANTY; without even the implied warranty of
33  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
34  * GNU General Public License for more details.
35  *
36  * You should have received a copy of the GNU General Public License along
37  * with this program; if not, write to the Free Software Foundation, Inc.,
38  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
39  * --------------------------------------------------------------------------
40  */
41 #ifndef OUTPUTMESSAGE_H
42 #define OUTPUTMESSAGE_H
43 
44 #include <ipcmsgtypes.h>
45 #include <ostream>
46 
51 class OutputMessage
52 {
53 public:
54  OutputMessage();
55  virtual ~OutputMessage() {
56  }
57 
58  virtual IpcMessageTypes getType() const = 0;
59 
63  virtual bool process() = 0;
64 
68  virtual bool send(std::ostream &) = 0;
69 
75  virtual size_t sendBinary(void *buffer, size_t maxlen) = 0;
76 
77  template <typename T>
78  size_t put (void *buffer, size_t index, T v) {
79  for (size_t i = 0; i < sizeof(T); ++i) {
80  *((char *)buffer + index + i) = *((char *)&v + i);
81  }
82  return index + sizeof(T);
83  }
84 };
85 
86 #endif // OUTPUTMESSAGE_H
an abstract class to serialize outputs through the OutputQueueManager
Definition: noipc.h:11
IpcMessageTypes
Definition: ipcmsgtypes.h:47
virtual IpcMessageTypes getType() const =0
virtual size_t sendBinary(void *buffer, size_t maxlen)=0
formats a binary block of data to be sent across the IPC stream
OutputMessage()
Definition: outputmessage.cpp:23
virtual bool process()=0
perform an operation non related to the gui feedback channel
size_t put(void *buffer, size_t index, T v)
Definition: outputmessage.h:78
virtual ~OutputMessage()
Definition: outputmessage.h:55
virtual bool send(std::ostream &)=0
the operation to perform.