DABC (Data Acquisition Backbone Core)
2.9.9
|
Client transport for different kinds of MBS server. More...
#include <mbs/ClientTransport.h>
Public Member Functions | |
ClientTransport (int fd, int kind) | |
int | Kind () const |
virtual unsigned | Read_Complete (dabc::Buffer &buf) |
Complete reading of the buffer from source,. More... | |
virtual unsigned | Read_Size () |
Defines required buffer size for next operation. More... | |
virtual unsigned | Read_Start (dabc::Buffer &buf) |
Prepare buffer for reading (if required) More... | |
virtual double | Read_Timeout () |
Provide timeout value. More... | |
virtual | ~ClientTransport () |
Public Member Functions inherited from dabc::SocketIOAddon | |
void | CancelIOOperations () |
Method should be used to cancel all running I/O operation of the socket. More... | |
void | SetSendAddr (const std::string &host="", int port=0) |
Set destination address for all send operations,. More... | |
SocketIOAddon (int fd=0, bool isdatagram=false, bool usemsg=true) | |
Constructor of SocketIOAddon class. More... | |
bool | StartNetRecv (void *hdr, unsigned hdrsize, Buffer &buf, BufferSize_t datasize) |
bool | StartNetSend (void *hdr, unsigned hdrsize, const Buffer &buf) |
bool | StartRecv (Buffer &buf, BufferSize_t datasize) |
bool | StartRecv (void *buf, size_t size) |
bool | StartRecvHdr (void *hdr, unsigned hdrsize, void *buf, size_t size) |
bool | StartSend (const Buffer &buf) |
bool | StartSend (const void *buf, unsigned size, const void *buf2=0, unsigned size2=0, const void *buf3=0, unsigned size3=0) |
virtual | ~SocketIOAddon () |
Destructor of SocketIOAddon class. More... | |
Public Member Functions inherited from dabc::SocketAddon | |
void | CloseSocket () |
bool | IsDeliverEventsToWorker () const |
bool | IsDoingInput () const |
bool | IsDoingOutput () const |
bool | IsSocket () const |
virtual std::string | RequiredThrdClass () const |
void | SetDeliverEventsToWorker (bool on=true) |
void | SetIOPriority (int prior=1) |
Method defines priority level for socket IO events. More... | |
void | SetSocket (int fd) |
int | Socket () const |
SocketAddon (int fd=-1) | |
int | TakeSocket () |
int | TakeSocketError () |
virtual | ~SocketAddon () |
Public Member Functions inherited from dabc::WorkerAddon | |
WorkerAddon (const std::string &name) | |
virtual | ~WorkerAddon () |
Public Member Functions inherited from dabc::Object | |
bool | AddChild (Object *child, bool withmutex=true) throw () |
Add object to list of child objects, thread safe More... | |
bool | AddChildAt (Object *child, unsigned pos, bool withmutex=true) |
Add object to list of child objects at specified position. More... | |
virtual void | BuildFieldsMap (RecordFieldsMap *cont) |
Fill fields map, which is relevant for the object Objects hierarchy produced from dabc::Manager. More... | |
virtual bool | Find (ConfigIO &cfg) |
Method to locate object in xml file. More... | |
Object * | FindChild (const char *name) const |
returns pointer on child object with given name More... | |
Reference | FindChildRef (const char *name, bool force=false) const throw () |
returns reference on child object with given name More... | |
bool | GetAllChildRef (ReferencesVector *vect) const |
Object * | GetChild (unsigned n) const |
returns pointer on child object More... | |
Reference | GetChildRef (unsigned n) const |
returns reference on child object More... | |
Reference | GetFolder (const std::string &name, bool force=false) throw () |
Return folder of specified name, no special symbols allowed. More... | |
const char * | GetName () const |
Returns name of the object, thread safe More... | |
Object * | GetParent () const |
Returns pointer on parent object, thread safe More... | |
Reference | GetParentRef () const |
bool | IsChildsHidden () const |
Return true if object wants to hide childs from hierarchy scan, thread safe More... | |
bool | IsHidden () const |
Return true if object wants to be hidden from hierarchy scan, thread safe More... | |
bool | IsLogging () const |
Return true if object selected for logging, thread safe More... | |
bool | IsName (const char *str) const |
Checks if object name is same as provided string, thread safe More... | |
bool | IsName (const char *str, int len) const |
Checks if object name is same as provided, thread safe More... | |
bool | IsName (const std::string &str) const |
Checks if object name is same as provided string, thread safe More... | |
bool | IsNameMatch (const std::string &mask) const |
Check if object name match to the mask. More... | |
bool | IsOwner () const |
Returns true if object is owner of its children, thread safe More... | |
bool | IsParent (Object *obj) const |
Checks if specified argument is in the list of object parents. More... | |
bool | IsTopXmlLevel () const |
Return true if object should be searched in the top level of the xml file, thread safe More... | |
std::string | ItemName (bool compact=true) const |
Produce string, which can be used as name argument in dabc::mgr.FindItem(name) call. More... | |
unsigned | NumChilds () const |
returns number of child objects More... | |
Object (const std::string &name, unsigned flags=flIsOwner) | |
Resolve problem with child-parent mutex locking. More... | |
Object (Reference parent, const std::string &name, unsigned flags=flIsOwner) | |
virtual void | Print (int lvl=0) |
Print object content on debug output. More... | |
bool | RemoveChild (Object *child, bool cleanup=true) throw () |
Detach child from parent object If cleanup==true and parent is owner of child, child will be destroyed. More... | |
bool | RemoveChildAt (unsigned n, bool cleanup=true) throw () |
Detach child object from parent at specified position If cleanup==true and object is owner of child, child will be destroyed. More... | |
bool | RemoveChilds (bool cleanup=true) |
Remove all childs. More... | |
void | SetLogging (bool on=true) |
Sets logging flag, thread safe More... | |
virtual | ~Object () |
Public Member Functions inherited from dabc::DataInput | |
virtual bool | Read_Init (const WorkerRef &wrk, const Command &cmd) |
Initialize data input, using port and command. More... | |
virtual bool | Read_Stat (dabc::Command cmd) |
Provide timeout value. More... | |
Buffer | ReadBuffer () |
Reads complete buffer. More... | |
virtual | ~DataInput () |
Protected Types | |
enum | EEvents { evDataInput = evntSocketLast , evReactivate } |
enum | EIOState { ioInit , ioRecvInfo , ioReady , ioRecvHeader , ioWaitBuffer , ioRecvBuffer , ioComplBuffer , ioClosing , ioError , ioClosed } |
Protected Types inherited from dabc::Object | |
enum | EFlags { flStateMask = 0x000f , flIsOwner = 0x0010 , flCleanup = 0x0020 , flHasThread = 0x0040 , flAutoDestroy = 0x0080 , flLogging = 0x0100 , flNoMutex = 0x0200 , flHidden = 0x0400 , flChildsHidden = 0x0800 , flTopXmlLevel = 0x1000 } |
Protected Member Functions | |
bool | IsDabcEnabledOnMbsSide () |
void | MakeCallback (unsigned sz) |
virtual void | ObjectCleanup () |
User method to cleanup object content before it will be destroyed Main motivation is to release any references on other objects to avoid any cross-references and as result deadlocks in objects cleanup. More... | |
virtual void | OnRecvCompleted () |
Method called when receive operation is completed. More... | |
virtual void | OnSendCompleted () |
Method called when send operation is completed. More... | |
virtual void | OnSocketError (int err, const std::string &info) |
Generic error handler. More... | |
virtual void | OnThreadAssigned () |
virtual void | ProcessEvent (const dabc::EventId &) |
virtual double | ProcessTimeout (double last_diff) |
virtual dabc::WorkerAddon * | Read_GetAddon () |
Returns addon, provided by data input If specified, supposed that I/O object is double-deriver from DataInput and Addon. More... | |
unsigned | ReadBufferSize () |
void | SubmitRequest () |
Protected Member Functions inherited from dabc::SocketIOAddon | |
void | AllocateRecvIOV (unsigned size) |
void | AllocateSendIOV (unsigned size) |
virtual const char * | ClassName () const |
Returns class name of the object instance. More... | |
struct sockaddr_in & | GetRecvAddr () |
Method provide address of last receive operation. More... | |
unsigned | GetRecvSize () const |
Method return size of last buffer read from socket. More... | |
bool | IsDatagramSocket () const |
bool | IsDoingRecv () const |
bool | IsDoingSend () const |
Protected Member Functions inherited from dabc::SocketAddon | |
ssize_t | DoRecvBuffer (void *buf, ssize_t len) |
ssize_t | DoRecvBufferHdr (void *hdr, ssize_t hdrlen, void *buf, ssize_t len, void *srcaddr=0, unsigned srcaddrlen=0) |
ssize_t | DoSendBuffer (void *buf, ssize_t len) |
ssize_t | DoSendBufferHdr (void *hdr, ssize_t hdrlen, void *buf, ssize_t len, void *tgtaddr=0, unsigned tgtaddrlen=0) |
bool | IsDeleteWorkerOnClose () const |
void | SetDeleteWorkerOnClose (bool on=true) |
void | SetDoingInput (bool on=true) |
Call method to indicate that object wants to read data from the socket. More... | |
void | SetDoingOutput (bool on=true) |
Call method to indicate that worker wants to write data to the socket. More... | |
Protected Member Functions inherited from dabc::WorkerAddon | |
bool | ActivateTimeout (double tmout_sec) |
void | DeleteAddonItself () |
This is possibility to delete addon itself, invoking worker command. More... | |
void | DeleteWorker () |
This is way to delete worker with addon inclusive. More... | |
void | FireWorkerEvent (unsigned evid) |
virtual long | Notify (const std::string &, int) |
Light-weight command interface, which can be used from worker. More... | |
void | SubmitWorkerCmd (Command cmd) |
Protected Member Functions inherited from dabc::Object | |
virtual void | _ChildsChanged () |
Method called when new childs are add or old are removed. More... | |
virtual bool | _DoDeleteItself () |
This method is called at the moment when DecReference think that object can be destroyed and wants to return true. More... | |
bool | _IsNormalState () |
Same as IsNormalState() but without mutex lock - user should lock mutex himself. More... | |
virtual Object * | CreateInstance (const std::string &name) |
Method used to create new item to be placed as child of the object. More... | |
void | DeleteThis () |
Method should be used by the object to delete itself. More... | |
virtual bool | DestroyByOwnThread () |
Internal DABC method, used to activate object cleanup via object thread Returns: false - object cannot be cleanup by the thread, true - thread guarantees that DestroyCalledFromOwnThread() will be called from thread context. More... | |
bool | DestroyCalledFromOwnThread () |
Internal DABC method, should be called by thread which was requested to destroy object. More... | |
void | FillFullName (std::string &fullname, Object *upto, bool exclude_top_parent=false) const |
Method used to produce full item name,. More... | |
bool | GetFlag (unsigned fl) const |
Return value of selected flag, not thread safe More... | |
bool | IsNormalState () |
Return true if object is in normal state. More... | |
unsigned | NumReferences () |
Return number of references on the object. More... | |
Object (const ConstructorPair &pair, unsigned flags=flIsOwner) | |
virtual void | ObjectDestroyed (Object *) |
Method called by the manager when registered dependent object is destroyed Should be used in user class to clear all references on the object to let destroy it. More... | |
Mutex * | ObjectMutex () const |
Returns mutex, used for protection of Object data members. More... | |
void | SetAutoDestroy (bool on=true) |
Set autodestroy flag for the object Once enabled, object will be destroyed when last reference will be cleared. More... | |
void | SetFlag (unsigned fl, bool on=true) |
Change value of selected flag, not thread safe More... | |
void | SetName (const char *name) |
Changes object name. More... | |
void | SetNameDirect (const char *name) |
Changes object name disregard of existing references. More... | |
void | SetOwner (bool on=true) |
Specifies if object will be owner of its new childs. More... | |
Protected Attributes | |
mbs::BufferHeader | fHeader |
int | fKind |
bool | fPendingStart |
char | fSendBuf [12] |
mbs::TransportInfo | fServInfo |
dabc::Buffer | fSpanBuffer |
buffer rest, which should be copied and merged into next buffer More... | |
bool | fSpanning |
when true, MBS could deliver spanned events More... | |
EIOState | fState |
bool | fSwapping |
Protected Attributes inherited from dabc::SocketIOAddon | |
bool | fDatagramSocket |
indicate if socket is datagram and all operations should be finished with single call More... | |
unsigned | fLastRecvSize |
size of last recv operation More... | |
struct sockaddr_in | fRecvAddr |
source address of last receive operation More... | |
struct iovec * | fRecvIOV |
receive io vector for scatter list More... | |
unsigned | fRecvIOVFirst |
number of element in recv IOV where transfer is started More... | |
unsigned | fRecvIOVNumber |
number of elements in current recv operation More... | |
unsigned | fRecvIOVSize |
number of elements in recv vector More... | |
bool | fRecvUseMsg |
use recvmsg for transport More... | |
struct sockaddr_in | fSendAddr |
optional send address for next send operation More... | |
struct iovec * | fSendIOV |
sending io vector for gather list More... | |
unsigned | fSendIOVFirst |
number of element in send IOV where transfer is started More... | |
unsigned | fSendIOVNumber |
number of elements in current send operation More... | |
unsigned | fSendIOVSize |
total number of elements in send vector More... | |
bool | fSendUseAddr |
if true, fSendAddr will be used More... | |
bool | fSendUseMsg |
use sendmsg for transport More... | |
bool | fUseMsgOper |
indicate if sendmsg, recvmsg operations should be used, it is must for the datagram sockets More... | |
Protected Attributes inherited from dabc::SocketAddon | |
bool | fDeleteWorkerOnClose |
if true, worker will be deleted when socket closed or socket in error More... | |
bool | fDeliverEventsToWorker |
if true, completion events will be delivered to the worker More... | |
bool | fDoingInput |
true if input data are expected More... | |
bool | fDoingOutput |
true if data need to be send More... | |
int | fIOPriority |
priority of socket I/O events, default 1 More... | |
int | fSocket |
socket handle More... | |
Protected Attributes inherited from dabc::WorkerAddon | |
Reference | fWorker |
Protected Attributes inherited from dabc::Object | |
int | fObjectBlock |
counter for blocking calls, as long as non-zero, non of child can be removed More... | |
ReferencesVector * | fObjectChilds |
list of the child objects More... | |
unsigned | fObjectFlags |
flag, protected by the mutex More... | |
Mutex * | fObjectMutex |
mutex protects all private property of the object More... | |
std::string | fObjectName |
object name More... | |
Reference | fObjectParent |
reference on the parent object More... | |
int | fObjectRefCnt |
accounts how many references existing on the object, thread safe More... | |
Additional Inherited Members | |
Public Types inherited from dabc::SocketAddon | |
enum | ESocketEvents { evntSocketRead = Worker::evntFirstAddOn , evntSocketWrite , evntSocketError , evntSocketStartConnect , evntSocketLast , evntSocketRecvInfo = Worker::evntFirstSystem , evntSocketSendInfo , evntSocketErrorInfo , evntSocketCloseInfo , evntSocketLastInfo } |
Static Public Member Functions inherited from dabc::Object | |
static void | Destroy (Object *obj) throw () |
User method for object destroyment. More... | |
static void | InspectGarbageCollector () |
\ brief Methods to inspect how many objects pointers are remained More... | |
static bool | NameMatch (const std::string &name, const std::string &mask) |
Check if name matches to specified mask. More... | |
static bool | NameMatchM (const std::string &name, const std::string &mask) |
Check if name matches to specified mask. More... | |
static unsigned | NumInstances () |
Static variable counts total number of objects instances. More... | |
Static Protected Member Functions inherited from dabc::Object | |
static ConstructorPair | MakePair (const std::string &fullname, bool withmanager=true) |
Internal DABC method, used to produce pair - object parent and object name, which is typically should be used as argument in class constructor. More... | |
static ConstructorPair | MakePair (Object *prnt, const std::string &fullname, bool withmanager=true) |
Internal DABC method, used to produce pair - object parent and object name, which is typically should be used as argument in class constructor. More... | |
static ConstructorPair | MakePair (Reference prnt, const std::string &fullname, bool withmanager=true) |
Internal DABC method, used to produce pair - object parent and object name, which is typically should be used as argument in class constructor. More... | |
Client transport for different kinds of MBS server.
Definition at line 35 of file ClientTransport.h.
|
protected |
Enumerator | |
---|---|
ioInit | |
ioRecvInfo | |
ioReady | |
ioRecvHeader | |
ioWaitBuffer | |
ioRecvBuffer | |
ioComplBuffer | |
ioClosing | |
ioError | |
ioClosed |
Definition at line 40 of file ClientTransport.h.
|
protected |
Enumerator | |
---|---|
evDataInput | |
evReactivate |
Definition at line 53 of file ClientTransport.h.
mbs::ClientTransport::ClientTransport | ( | int | fd, |
int | kind | ||
) |
Definition at line 22 of file ClientTransport.cxx.
|
virtual |
Definition at line 37 of file ClientTransport.cxx.
|
protectedvirtual |
User method to cleanup object content before it will be destroyed Main motivation is to release any references on other objects to avoid any cross-references and as result deadlocks in objects cleanup.
Method is called in context of thread, to which object belongs to. If user redefines this method, he is responsible to call method of parent class
Reimplemented from dabc::WorkerAddon.
Definition at line 42 of file ClientTransport.cxx.
|
protectedvirtual |
Reimplemented from dabc::WorkerAddon.
Definition at line 194 of file ClientTransport.cxx.
|
protectedvirtual |
Reimplemented from dabc::WorkerAddon.
Definition at line 212 of file ClientTransport.cxx.
|
protectedvirtual |
Reimplemented from dabc::SocketIOAddon.
Definition at line 73 of file ClientTransport.cxx.
|
protectedvirtual |
Method called when send operation is completed.
Reimplemented from dabc::SocketIOAddon.
Definition at line 78 of file ClientTransport.cxx.
|
protectedvirtual |
Method called when receive operation is completed.
Reimplemented from dabc::SocketIOAddon.
Definition at line 82 of file ClientTransport.cxx.
|
protectedvirtual |
Generic error handler.
Also invoked when socket is closed (msg==0)
Reimplemented from dabc::SocketAddon.
Definition at line 175 of file ClientTransport.cxx.
|
protected |
Definition at line 222 of file ClientTransport.cxx.
|
protected |
Definition at line 233 of file ClientTransport.cxx.
|
protected |
Definition at line 61 of file ClientTransport.cxx.
|
protected |
Definition at line 56 of file ClientTransport.cxx.
|
inlineprotectedvirtual |
Returns addon, provided by data input If specified, supposed that I/O object is double-deriver from DataInput and Addon.
Reimplemented from dabc::DataInput.
Definition at line 94 of file ClientTransport.h.
|
inline |
Definition at line 101 of file ClientTransport.h.
|
virtual |
Defines required buffer size for next operation.
Reimplemented from dabc::DataInput.
Definition at line 248 of file ClientTransport.cxx.
|
virtual |
Prepare buffer for reading (if required)
Reimplemented from dabc::DataInput.
Definition at line 265 of file ClientTransport.cxx.
|
virtual |
Complete reading of the buffer from source,.
Reimplemented from dabc::DataInput.
Definition at line 314 of file ClientTransport.cxx.
|
inlinevirtual |
Provide timeout value.
When Read_Size or Read_Complete operations returns di_RepeatTimeout argument, specified timeout will be used before next operation will be done
Reimplemented from dabc::DataInput.
Definition at line 109 of file ClientTransport.h.
|
protected |
Definition at line 58 of file ClientTransport.h.
|
protected |
Definition at line 59 of file ClientTransport.h.
|
protected |
Definition at line 60 of file ClientTransport.h.
|
protected |
when true, MBS could deliver spanned events
Definition at line 61 of file ClientTransport.h.
|
protected |
Definition at line 63 of file ClientTransport.h.
|
protected |
Definition at line 64 of file ClientTransport.h.
|
protected |
Definition at line 66 of file ClientTransport.h.
|
protected |
Definition at line 68 of file ClientTransport.h.
|
protected |
buffer rest, which should be copied and merged into next buffer
Definition at line 70 of file ClientTransport.h.