ug4
|
CRTP Base class for communications on layout/interfaces. More...
#include <communication_scheme.h>
Public Member Functions | |
virtual bool | collect (ug::BinaryBuffer &buff, const Interface &interface) |
send data on the interface based on TDerived::send More... | |
TDerived & | derived () |
get the derived class More... | |
virtual bool | extract (ug::BinaryBuffer &buff, const Interface &interface) |
receive data on the interface and hand it over to TDerived::receive More... | |
virtual int | get_required_buffer_size (const Interface &interface) |
get the size of the required buffer for an interface More... | |
Public Member Functions inherited from pcl::ICommunicationPolicy< IndexLayout > | |
virtual bool | begin_layout_collection (const Layout *pLayout) |
signals the beginning of a layout collection. More... | |
virtual bool | begin_layout_extraction (const Layout *pLayout) |
signals the beginning of a layout extraction. More... | |
virtual void | begin_level_extraction (int level) |
signals that a new layout-level will now be processed. More... | |
virtual bool | end_layout_collection (const Layout *pLayout) |
signals the end of a layout collection More... | |
virtual bool | end_layout_extraction (const Layout *pLayout) |
signals the end of a layout extraction More... | |
virtual | ~ICommunicationPolicy () |
Additional Inherited Members | |
Public Types inherited from pcl::ICommunicationPolicy< IndexLayout > | |
typedef Layout::Interface | Interface |
typedef IndexLayout | Layout |
CRTP Base class for communications on layout/interfaces.
CommunicationScheme is a base class for a recurring programming task: You want to send data over a layout/interface. Now you just need to specify what to to at each index on the receiver side, and on each index on the sender side Example with own CommunicationScheme
to use it, you just need to write
and all slave nodes have been added the master nodes. (here slaveLayout is the receiving, and masterLayout is the sending Scheme)
Example with StdArrayCommunicationScheme
:
Now all master nodes have overwritten the data on the slave nodes. note that instead of int you can use any type for there is Serialize/Deserialize, so also: string
, map
, int
, char
, double
and so on. There is also a specialization for bool
which uses only 1 bit for each bool
.
StdArrayCommunicationScheme
const TValue &send(int pid, size_t index) const
void receive(int pid, size_t index, value_type &v)
inline int get_element_size() const
TDerived | Derived class |
TValue |
|
inlinevirtual |
send data on the interface based on TDerived::send
collect
buff | BinaryBuffer to write data to |
interface | interface to pid over which to send This function does the following
|
Implements pcl::ICommunicationPolicy< IndexLayout >.
References pcl::OrderedInterface< TType, TContainer, TAlloc >::begin(), ug::CommunicationScheme< TDerived, TValue >::derived(), pcl::OrderedInterface< TType, TContainer, TAlloc >::end(), pcl::OrderedInterface< TType, TContainer, TAlloc >::get_element(), pcl::OrderedInterface< TType, TContainer, TAlloc >::get_target_proc(), and ug::Serialize().
|
inline |
get the derived class
Referenced by ug::CommunicationScheme< TDerived, TValue >::collect(), ug::CommunicationScheme< TDerived, bool >::collect(), ug::CommunicationScheme< TDerived, TValue >::extract(), ug::CommunicationScheme< TDerived, bool >::extract(), and ug::CommunicationScheme< TDerived, TValue >::get_required_buffer_size().
|
inlinevirtual |
receive data on the interface and hand it over to TDerived::receive
extract
buff | BinaryBuffer with the data we received from processor pid. |
interface | interface to processor pid This function does the following *
|
Implements pcl::ICommunicationPolicy< IndexLayout >.
References pcl::OrderedInterface< TType, TContainer, TAlloc >::begin(), ug::CommunicationScheme< TDerived, TValue >::derived(), ug::Deserialize(), pcl::OrderedInterface< TType, TContainer, TAlloc >::end(), pcl::OrderedInterface< TType, TContainer, TAlloc >::get_element(), and pcl::OrderedInterface< TType, TContainer, TAlloc >::get_target_proc().
|
inlinevirtual |
get the size of the required buffer for an interface
get_required_buffer_size
interface | The interface so we can calculate the size If TDerived can specify an exact size for each item it serializes, we can calculate the size of the buffer otherwise, it returns -1, and we return -1 -> Buffer size is sent. |
Reimplemented from pcl::ICommunicationPolicy< IndexLayout >.
References ug::CommunicationScheme< TDerived, TValue >::derived(), s, and pcl::OrderedInterface< TType, TContainer, TAlloc >::size().