GyrosCommsInterface.hpp
Go to the documentation of this file.
00001 /*
00002  * GyrosCommsInterface.hpp
00003  *
00004  *  Created on: Feb 14, 2011
00005  *      Author: Tomislav Lugaric
00006  *
00007  * This class represents an abstract communication interface
00008  * The communication interface is configured from an XML file
00009  * It uses a standardised xml based data format for communication
00010  * It can operate in active or passive mode
00011  * In active mode, the interface carries out operations when data is sent or received
00012  * In passive mode, an external object polls the interface for data
00013  * 
00014  */
00015 
00016 #ifndef GYROSCOMMSINTERFACE_HPP_
00017 #define GYROSCOMMSINTERFACE_HPP_
00018 
00019 #include <LABUSTTypes.h>
00020 #include <string>
00021 #include <labust/xml/GyrosReader.hpp>
00022 #include <labust/xml/GyrosWriter.hpp>
00023 #include <labust/xml/GyrosMatrix.hpp>
00024 #include <boost/smart_ptr.hpp>
00025 
00026 #include <labust/plugins/Factory.hpp>
00027 #include <labust/plugins/DLLoad.hpp>
00028 #include <labust/xml/xmlfwd.hpp>
00029 
00030 namespace LABUST
00031 {
00032     namespace COMMUNICATION
00033     {
00034 
00035         namespace COMMERRORS
00036         {
00037 
00038             enum CommError
00039             {
00040                 notImplemented = -2, // for functions that do not have an implementation (e.g. optional legacy functions)
00041                 undefined = -1, // generic error
00042                 noError = 0,
00043                 noData = 1,
00044                 callbackRegistered,
00045                 communicationFailed, // for send/receive
00046                 commsMisconfigured // if interface is not successfully configured
00047             };
00048         }
00049 
00053         class CommEntity
00054         {
00055         public:
00064             virtual int AcceptData(std::vector<labust::xml::GyrosReader> &data) = 0;
00065         private:
00066 
00067         };
00068 
00078         class GyrosCommsInterface
00079         {
00080         public:
00081 
00082             GyrosCommsInterface():
00083                         connected(false)
00084                         {};
00085 
00086             /*
00087              * Destructor, if interface needs to be explicitely terminated, put code here
00088              */
00089             virtual ~GyrosCommsInterface()
00090             {
00091             }
00092 
00103             virtual COMMERRORS::CommError Send(const labust::xml::GyrosWriter &data, bool wait = false) = 0;
00104 
00115             virtual COMMERRORS::CommError Send(const std::vector<labust::xml::GyrosWriter> &data, bool wait = false) = 0;
00116 
00128             virtual COMMERRORS::CommError Receive(std::vector<labust::xml::GyrosReader> &data, bool wait = false) = 0;
00129 
00137             virtual const void* GetCommObject(void)
00138             {
00139                 return NULL;
00140             };
00141 
00151             virtual void RegisterCallbackObject(CommEntity *entity)
00152             {
00153                 this->callbackObject = entity;
00154             };
00155 
00160             virtual void unRegisterCallbackObject()
00161             {
00162                 this->callbackObject = NULL;
00163             };
00164 
00165                         inline const bool Connected()
00166                         {
00167                                 return connected;
00168                         }
00169         protected:
00170 
00175             CommEntity *callbackObject;
00176 
00177                         bool connected;
00178         private:
00179             /*
00180              * Noncopyable
00181              */
00182             GyrosCommsInterface(const GyrosCommsInterface& orig);
00183             GyrosCommsInterface & operator =(const GyrosCommsInterface &);
00184         };
00185 
00186 
00187         typedef boost::shared_ptr<GyrosCommsInterface> GyrosCommsInterfacePtr;
00188 
00189 
00190     //Plugin factory typedef
00191     typedef labust::plugins::TmplPluginFactory<
00192       GyrosCommsInterface,
00193       const labust::xml::Reader&,
00194       const std::string&> CommsFactory;
00195     //Factory typedef
00196     typedef CommsFactory::AbstractFactory* CommsFactoryPtr;
00197 
00198     typedef labust::plugins::DLLoad<LABUST::COMMUNICATION::CommsFactory> CommsPlugin;
00199     typedef boost::shared_ptr<CommsPlugin> CommsPluginPtr;
00200  
00201 
00202     };
00203 };
00204 #endif /* GYROSCOMMSINTERFACE_HPP_ */


acoustic_vr
Author(s):
autogenerated on Fri Feb 7 2014 11:37:09