IGSTK
igstkCommunication.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Image Guided Surgery Software Toolkit
4  Module: $RCSfile: igstkCommunication.h,v $
5  Language: C++
6  Date: $Date: 2011-01-18 21:40:16 $
7  Version: $Revision: 1.24 $
8 
9  Copyright (c) ISC Insight Software Consortium. All rights reserved.
10  See IGSTKCopyright.txt or http://www.igstk.org/copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 
18 #ifndef __igstkCommunication_h
19 #define __igstkCommunication_h
20 
21 
22 #include "igstkObject.h"
23 #include "igstkMacros.h"
24 #include "igstkStateMachine.h"
25 
26 
27 namespace igstk
28 {
37 class Communication : public Object
38 {
39 
40 public:
41 
44 
45 public:
46 
47  typedef enum
48  {
49  FAILURE=0,
50  SUCCESS=1,
51  TIMEOUT=2
52  } ResultType;
53 
56  virtual ResultType OpenCommunication( void );
57 
59  virtual ResultType CloseCommunication( void );
60 
65  igstkSetMacro( TimeoutPeriod, unsigned int );
66  igstkGetMacro( TimeoutPeriod, unsigned int );
67 
71  igstkSetMacro( ReadTerminationCharacter, char );
72  igstkGetMacro( ReadTerminationCharacter, char );
73 
76  igstkSetMacro( UseReadTerminationCharacter, bool );
77  igstkGetMacro( UseReadTerminationCharacter, bool );
78 
80  virtual ResultType Write( const char * /* data */,
81  unsigned int /* numberOfBytes */ ) { return SUCCESS; }
82 
84  virtual ResultType Read( char * /* data */,
85  unsigned int /* numberOfBytes */,
86  unsigned int & /* bytesRead */ ) { return SUCCESS; }
87 
88 protected:
89 
92  Communication( void );
93 
94  virtual ~Communication( void );
95 
97  virtual void PrintSelf( std::ostream& os, itk::Indent indent ) const;
98 
99 private:
100 
101  unsigned int m_TimeoutPeriod;
102 
103  char m_ReadTerminationCharacter;
104 
105  bool m_UseReadTerminationCharacter;
106 };
107 
108 } // end of namespace igstk
109 
110 #endif //__igstk_Communication_h_
Communication(void)
Constructor is protected in order to enforce the use of the New() operator.
#define igstkGetMacro(name, type)
Get built-in type.
Definition: igstkMacros.h:105
Base class for all the IGSTK classes.
Definition: igstkObject.h:40
#define igstkStandardClassTraitsMacro(classname, superclassname)
Convenience macro for traits of a non-templated class.
Definition: igstkMacros.h:275
defines standard system-wide macros, constants, and other common parameters in the IGSTK Library...
Class Communication is the base class for communication between the tracker class and the hardware tr...
virtual ResultType Write(const char *, unsigned int)
Write method sends the string via communication link.
virtual ResultType CloseCommunication(void)
The method CloseCommunication closes the communication.
#define igstkSetMacro(name, type)
Set built-in type.
Definition: igstkMacros.h:93
virtual void PrintSelf(std::ostream &os, itk::Indent indent) const
Print object information.
virtual ResultType Read(char *, unsigned int, unsigned int &)
Read method receives string via communication link.
virtual ~Communication(void)