trick/include/trick/MessageTCDevice.hh
Alex Lin 19025d77ad Standardize directory names
Reorganized.  Created a new top level include directory that will hold all of Trick's header files. Moved all of the Trick headers to this directory.  Created a libexec directory that holds all of the executables that users don't need to execute directly.  Changed all of the executables remaining in bin to start with "trick-".  In the sim_services directories changed all source files to find the Trick headers in their new location.  Since all of the include files are gone in sim_services, removed the src directories as well, moving all of the source files up a level.  Moved the makefiles, docs, man, and other architecture independent files into a top level share directory.  Renamed lib_${TRICK_HOST_CPU} to lib64 or lib depending on the platform we're currently on.

refs #63
2015-06-09 08:44:42 -05:00

121 lines
3.3 KiB
C++

#ifndef MESSAGETCDEVICE_HH
#define MESSAGETCDEVICE_HH
#include <pthread.h>
#include <vector>
#include "trick/MessageSubscriber.hh"
#include "trick/ThreadBase.hh"
#include "trick/tc.h"
namespace Trick {
class MessageTCDevice ;
class MessageTCDeviceListenThread : public Trick::ThreadBase {
public:
MessageTCDeviceListenThread(MessageTCDevice * in_mtcd) ;
virtual ~MessageTCDeviceListenThread() ;
int get_port() ;
int init_listen_device() ;
int restart() ;
virtual void * thread_body() ;
virtual void dump( std::ostream & oss = std::cout ) ;
protected:
/** Pointer back to MessageTCDevice\n */
MessageTCDevice * mtcd ; /**< trick_io(**) */
/** No handshake message server listen device.\n */
TCDevice listen_dev ; /**< trick_io(**) trick_units(--) */
} ;
/**
* This MessageTCDevice is a class that inherits from MessageSubscriber.
* It defines a type of MessageSubscriber that sends the messages to a receiver
* through TCDevice when a proper socket connection is established.
* Basically, it has a message server listen TCDevice that receives all the message
* updates from a message publisher which it subscribes to and then writes the message
* updates to all the connections it has if possible.
*/
class MessageTCDevice : public MessageSubscriber {
public:
/**
@brief The constructor.
*/
MessageTCDevice();
/**
@brief The destructor.
*/
~MessageTCDevice();
/**
@brief Gets the listen thread.
*/
Trick::MessageTCDeviceListenThread & get_listen_thread() ;
/**
@brief Adds a new connection. Called from MessageTCDeviceListenThread
*/
void add_connection( TCDevice * new_conn ) ;
/**
@brief Send the header & message to all open connections.
*/
virtual void update( unsigned int level , std::string header, std::string message );
/**
@brief Initializes this subscriber.
@return always 0
*/
int default_data() ;
/**
@brief Initializes this subscriber.
@return always 0
*/
int init() ;
/**
@brief Restarts this subscriber.
@return always 0
*/
int restart() ;
/**
@brief Shuts down this subscriber.
@return always 0
*/
int shutdown() ;
/** The port number for message socket connection. Copied out from listen_thread.\n */
int port ; /**< trick_units(--) */
private:
/** Thread to start listen device\n */
MessageTCDeviceListenThread listen_thread ;
/** Message buffer.\n */
char * combined_message ; /**< trick_io(**) trick_units(--) */
/** List of open connections.\n */
std::vector< TCDevice *> connections ; /**< trick_io(**) trick_units(--) */
} ;
}
#endif