Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
CScommClasses.hh
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5 Multimediale Systeme der Informationsverarbeitung
6 Institut fuer Informatik
7 Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 #ifndef _CScommClasses_
26 #define _CScommClasses_
27 
28 #include <bias_config.h>
29 #ifndef BIAS_HAVE_PTHREADS
30 # error BIAS_HAVE_PTHREADS not defined. But BIASNetworkComm needs pthreads (on Unix and Win32). Please enable USE_PTHREADS in CMake configure step.
31 #endif
32 #include <pthread.h>
33 
34 namespace BIAS {
35 
37 
38  /**
39  @class CScommMsg
40  @brief helper class for CScommBase
41  @ingroup network
42  */
43  class BIASNetworkComm_EXPORT CScommMsg {
44  public:
45  CScommMsg() : newData(false) {}
46  std::string msgName;
47  std::string commName;
48  bool server; // if this msg is accepted by the server or client
49  EdataType dataType; // which kind of data (for parsing)
50  unsigned int dataSize; // how many FLOATS or INTs...
51  bool newData;
52  pthread_mutex_t dataLock;
53 
54  // only one of the following is used for a msg
55  // and the main thread is only allowed to touch one of these
56  // with GetData()
57  std::vector<float> floatData;
58  std::vector<int> intData;
59  std::vector<std::string> stringData;
60  char* binaryData;
61  unsigned int binaryDataSize;
62  };
63 
64  /**
65  @class CScommData
66  @brief helper class for CScommBase
67  @ingroup network
68  */
69  class BIASNetworkComm_EXPORT CScommData
70  {
71  public:
72  CScommData() : connected(false), fd(-1), firstcontact(true)
73  {}
75 
76  std::string name;
77  pthread_t threadid;
78  bool connected;
79  int fd;
81  std::vector<char> msgBuffer; // for buffering of incomplete msgs
82  unsigned int lastProcessed;
83  };
84 
85  // forward declaration
86  class CScommBase;
87 
88  /**
89  @class CSCommWithClientNr
90  @brief helper class for CScommBase
91  @ingroup network
92  */
93  class BIASNetworkComm_EXPORT CSCommWithClientNr {
94  public:
96  int commNr;
97  };
98 
99 
100 
101 }
102 
103 #endif
unsigned int dataSize
helper class for CScommBase
std::string msgName
helper class for CScommBase
EdataType dataType
std::vector< std::string > stringData
this class CScomm (ClientServer communciation) handles data comunication via TCP/IP for one server an...
Definition: CScommBase.hh:73
unsigned int lastProcessed
std::string name
unsigned int binaryDataSize
helper class for CScommBase
std::string commName
std::vector< int > intData
pthread_t threadid
std::vector< float > floatData
std::vector< char > msgBuffer
pthread_mutex_t dataLock