ROOT  6.06/09
Reference Guide
Typedefs | Functions
MPSendRecv.h File Reference
#include "TBufferFile.h"
#include "TClass.h"
#include "TSocket.h"
#include <typeinfo>
#include <utility>
#include <memory>
#include <type_traits>
#include <iostream>
+ Include dependency graph for MPSendRecv.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

using MPCodeBufPair = std::pair< unsigned, std::unique_ptr< TBufferFile >>
 An std::pair that wraps the code and optional object contained in a message. More...
 

Functions

int MPSend (TSocket *s, unsigned code)
 Send a message with the specified code on the specified socket. More...
 
template<class T , typename std::enable_if< std::is_class< T >::value >::type * = nullptr>
int MPSend (TSocket *s, unsigned code, T obj)
 Send a message with a code and an object to socket s. More...
 
MPCodeBufPair MPRecv (TSocket *s)
 Receive message from a socket. More...
 
template<class T , typename std::enable_if< std::is_class< T >::value >::type * = nullptr>
ReadBuffer (TBufferFile *buf)
 One of the template functions used to read objects from messages. More...
 

Typedef Documentation

using MPCodeBufPair = std::pair<unsigned, std::unique_ptr<TBufferFile>>

An std::pair that wraps the code and optional object contained in a message.

Parameters
firstmessage code
seconda smart pointer to a TBufferFile that contains the message object
The smart pointer is null if the message does not contain an object but only consists of a code. See MPRecv() description on how to retrieve the object from the TBufferFile.

Definition at line 20 of file MPSendRecv.h.

Function Documentation

MPCodeBufPair MPRecv ( TSocket s)

Receive message from a socket.

This standalone function can be used to read a message that has been sent via MPSend(). The smart pointer contained in the returned MPCodeBufPair is null if the message does not contain an object, otherwise it points to a TBufferFile. To retrieve the object from the buffer different methods must be used depending on the type of the object to be read:

Definition at line 43 of file MPSendRecv.cxx.

Referenced by TProcPool::Collect(), and TMPWorker::Run().

int MPSend ( TSocket s,
unsigned  code 
)

Send a message with the specified code on the specified socket.

This standalone function can be used to send a code on a given socket. It does not check whether the socket connection is in a valid state. The message code can then be retrieved via MPRecv().
Note: only objects the headers of which have been parsed by cling can be sent by MPSend(). User-defined types can be made available to cling via a call like gSystem->ProcessLine("#include \\"header.h\""). Pointer types are not supported (with the exception of const char*), but the user can simply dereference the pointer and send the pointed object instead.
Note: for readability, codes should be enumerated as in EMPCode.

Parameters
sa pointer to a valid TSocket. No validity checks are performed
codethe code to be sent
Returns
the number of bytes sent, as per TSocket::SendRaw

Definition at line 21 of file MPSendRecv.cxx.

Referenced by TMPClient::Broadcast(), TMPWorker::HandleInput(), TPoolWorker< F, T, R >::HandleInput(), TPoolProcessor< F >::HandleInput(), TPoolWorker< F, void, R >::HandleInput(), TPoolWorker< F, T, void >::HandleInput(), TProcPool::HandlePoolCode(), TPoolProcessor< F >::OpenFile(), TPoolProcessor< F >::Process(), TProcPool::ReplyToFuncResult(), TProcPool::ReplyToIdle(), and TPoolProcessor< F >::RetrieveTree().

template<class T , typename std::enable_if< std::is_class< T >::value >::type * = nullptr>
int MPSend ( TSocket s,
unsigned  code,
obj 
)

Send a message with a code and an object to socket s.

The number of bytes sent is returned, as per TSocket::SendRaw. This standalone function can be used to send a code and possibly an object on a given socket. This function does not check whether the socket connection is in a valid state. MPRecv() must be used to retrieve the contents of the message.
Note: only objects the headers of which have been parsed by cling can be sent using MPSend(). User-defined types can be made available to cling via a call like gSystem->ProcessLine("#include \\"header.h\""). Pointer types cannot be sent via MPSend() (with the exception of const char*).

Parameters
sa pointer to a valid TSocket. No validity checks are performed
codethe code to be sent
objthe object to be sent
Returns
the number of bytes sent, as per TSocket::SendRaw

Definition at line 80 of file MPSendRecv.h.

template<class T , typename std::enable_if< std::is_class< T >::value >::type * = nullptr>
T ReadBuffer ( TBufferFile buf)

One of the template functions used to read objects from messages.

Different implementations are provided for different types of objects: classes, non-pointer built-ins and const char*. Reading pointers is not implemented (at the time of writing, sending pointers is not either).

Definition at line 146 of file MPSendRecv.h.

Referenced by TStreamerInfoActions::GenericReadAction().