charon-core  0.3.1
InputSlot< T > Class Template Reference

Input slot. More...

#include <charon-core/Slots.h>

Inheritance diagram for InputSlot< T >:

Public Member Functions

 InputSlot (bool optional=false, bool multi=false)
 Create new input slot. More...
 
virtual void finalize ()
 finalize slot More...
 
const T & getDataFromOutputSlot (const OutputSlotIntf *slot) const
 handle data extraction from output slot More...
 
const T & getDataFromOutputSlot (const Slot *slot) const
 handle data extraction from output slot More...
 
virtual std::string getName () const
 get the name
 
virtual std::string getType () const
 Get slot type. More...
 
virtual void load (const ParameterFile &pf, const PluginManagerInterface *man)
 Load slot connections. More...
 
virtual operator T () const
 Cast operator to get data (get copy) More...
 
virtual const T & operator() () const
 Call operator. More...
 
virtual const T & operator[] (std::size_t pos) const
 Access to specific member (read-only). More...
 
virtual void prepare ()
 prepare slot More...
 
virtual std::size_t size () const
 Access to number of members. More...
 
- Public Member Functions inherited from AbstractSlot< T >
virtual std::set< Slot * > getTargets () const
 Get pointers to the connected targets.
 
virtual std::string guessType () const
 Try to guess slot type.
 
virtual void save (ParameterFile &pf) const
 Save slot connections This function disconnects already established connections in the parameterFile and stores the current one. More...
 
std::set< AbstractSlot< T >
* >::const_iterator 
begin () const
 iterator to the beginning of the source list
 
std::set< AbstractSlot< T >
* >::const_iterator 
end () const
 iterator to the end of the source list
 
- Public Member Functions inherited from Slot
 Slot ()
 default constructor
 
bool connect (Slot &target)
 Connect with given slot. More...
 
bool connected () const
 Check if slot is connected.
 
bool connected (Slot &target) const
 Check if slot is connected to given slot. More...
 
bool disconnect ()
 Remove all slot targets.
 
bool disconnect (Slot &target)
 Remove all slot targets.
 
virtual std::string getDisplayName () const
 Get slot display name.
 
bool getMulti () const
 return value of _multiSlot;
 
bool getOptional () const
 return value of _optional;
 
ParameteredObjectgetParent ()
 get parent object
 
const ParameteredObjectgetParent () const
 get parent object (const version)
 
void init (ParameteredObject *parent, std::string name, std::string type)
 initialize parent and name More...
 
void init (ParameteredObject *parent, std::string name, std::string displayname, std::string type)
 initialize parent and name and displayname More...
 
void printError (const std::string &msg) const
 print error with slot name and type info to sout
 
void printInfo (const std::string &msg) const
 print info message with slot name to sout
 
void printWarning (const std::string &msg) const
 print warning message with slot name to sout
 
void raise (const std::string &msg) const
 throw runtime error with slot name and type info
 

Private Attributes

std::map< std::string, T > _dataCache
 data cache for managed output slots
 

Additional Inherited Members

- Public Types inherited from Slot
enum  CacheType { CACHE_INVALID, CACHE_MEM, CACHE_MANAGED }
 slot data cache type More...
 
- Protected Member Functions inherited from AbstractSlot< T >
virtual bool _addTarget (Slot *target)
 Add slot target. More...
 
virtual bool _removeTarget (Slot *target)
 Remove slot target. More...
 
- Protected Attributes inherited from AbstractSlot< T >
std::set< AbstractSlot< T > * > _targets
 Pointer to data of connected output slot.
 
- Protected Attributes inherited from Slot
std::string _displayName
 Slot display name.
 
bool _multiSlot
 flag to mark this slot as a multislot, that can have multiple sources/targets. More...
 
std::string _name
 Slot name.
 
bool _optional
 flag to mark this slot as optional
 
ParameteredObject_parent
 Pointer to parent object.
 
std::string _type
 Slot type.
 

Detailed Description

template<typename T>
class InputSlot< T >

This slot does not stores the data itself, but contains a pointer to the connected output slot. Data are read from this source, if needed.

Definition at line 312 of file Slots.h.

Constructor & Destructor Documentation

template<class T >
InputSlot< T >::InputSlot ( bool  optional = false,
bool  multi = false 
)
Parameters
optionalmake this slot optional
multimake this slot connectable to multiple slots

Definition at line 144 of file Slots.hxx.

Member Function Documentation

template<typename T >
void InputSlot< T >::finalize ( )
virtual

this may be used on input/output slots to save/free data memory

Implements Slot.

Definition at line 318 of file Slots.hxx.

template<typename T >
const T & InputSlot< T >::getDataFromOutputSlot ( const OutputSlotIntf slot) const
template<typename T >
const T & InputSlot< T >::getDataFromOutputSlot ( const Slot slot) const
Parameters
slotoutput slot to extract data from
Returns
extracted data

Definition at line 237 of file Slots.hxx.

References Slot::raise().

template<typename T>
virtual std::string InputSlot< T >::getType ( ) const
inlinevirtual

If "<T>" is found inside the type string, this will be replaced through the template type of the parent ParameteredObject.

Returns
std::string representation of the slot type

Reimplemented from AbstractSlot< T >.

Definition at line 349 of file Slots.h.

template<class T >
void InputSlot< T >::load ( const ParameterFile pf,
const PluginManagerInterface man 
)
virtual

Input slots set up the connection between slots calling _addTargets() on the partners to be connected via connect(). Output slots load their slot configuration, i.e. set up e.g. their cache type if specified in the parameter file.

Parameters
pfParameterFile to load from
manPluginManager to get the instances from

Implements Slot.

Definition at line 154 of file Slots.hxx.

References Slot::_multiSlot, Slot::_name, Slot::_parent, Slot::connect(), Slot::disconnect(), PluginManagerInterface::getInstance(), ParameterFile::getList(), ParameteredObject::getName(), ParameteredObject::getSlot(), ParameterFile::isSet(), and Slot::raise().

template<class T >
InputSlot< T >::operator T ( ) const
virtual
Returns
data content (copy)

Implements AbstractROData< T >.

Definition at line 200 of file Slots.hxx.

References Slot::raise().

template<class T >
const T & InputSlot< T >::operator() ( ) const
virtual
Returns
data content (const reference, no copy)

Implements AbstractROData< T >.

Definition at line 208 of file Slots.hxx.

References Slot::raise().

template<class T >
const T & InputSlot< T >::operator[] ( std::size_t  pos) const
virtual
Parameters
posdata position
Returns
data content at given position (read-only, no copy)

Implements AbstractMultiROData< T >.

Definition at line 216 of file Slots.hxx.

References AbstractSlot< T >::begin().

template<typename T >
void InputSlot< T >::prepare ( )
virtual

Here, all connected output slots are scanned for managed data cache. For managed output slots, the data is queried using the needed data manager and stored in the _dataCache map. This is neccessary because the access operators are defined as const operators and so are not able to allocate persistent memory causing the references to become invalid.

The _dataCache map is cleared in finalize(), this way, the memory is freed.

Implements Slot.

Definition at line 287 of file Slots.hxx.

References AbstractSlot< T >::begin(), Slot::CACHE_MANAGED, AbstractSlot< T >::end(), OutputSlotIntf::getCacheType(), OutputSlotIntf::getConfig(), Slot::DataManager< T >::getData(), Slot::DataManagerFactory< T >::getManager(), Slot::getType(), VirtualOutputSlot::getType(), and Slot::raise().

template<typename T >
std::size_t InputSlot< T >::size ( ) const
virtual

For iterations using operator[]

Returns
number of elements

Implements AbstractMultiROData< T >.

Definition at line 232 of file Slots.hxx.


The documentation for this class was generated from the following files: