55 Slot::raise(
"AbstractSlot::_addTarget: null pointer given");
60 this->
printError(
"Source slot of failed connection");
61 target->
printError(
"Target slot of failed connection");
62 Slot::raise(
"Cannot connect slots of different types.");
74 this->
printError(
"Source slot of failed connection");
75 target->
printError(
"Target slot of failed connection");
76 Slot::raise(
"Tried to add multiple targets to non-multi slot.");
84 Slot::raise(
"AbstractSlot::_removeTarget: null pointer given");
89 return (_targets.erase( abstarget) > 0);
100 res.insert(_targets.begin(), _targets.end());
107 std::vector<std::string> targetList;
108 typename std::set<AbstractSlot<T>*>::const_iterator slot;
109 for (slot = _targets.begin(); slot != _targets.end(); slot++)
110 targetList.push_back((*slot)->getParent().getName() +
"."
111 + (*slot)->getName());
112 if (targetList.size())
120 std::string::size_type pos =
_type.find(
"<t>");
121 if (pos != std::string::npos) {
122 std::string temp(this->
_type);
123 temp.replace(pos + 1, 1,
getParent().getTemplateType());
125 }
else if (
_type ==
"t") {
133 return _targets.begin();
138 return _targets.end();
164 std::vector<std::string> targetList = pf.
getList<std::string> (
169 Slot::raise(
"multiple targets but not a multi-slot");
172 if (!targetList.size())
176 typename std::vector<std::string>::const_iterator tStrIter;
179 for (tStrIter = targetList.begin(); tStrIter != targetList.end(); tStrIter++) {
181 tStrIter->find(
".")));
184 tStrIter->substr(tStrIter->find(
".") + 1));
202 Slot::raise(
"access to unconnected input slot (cast operator)");
210 Slot::raise(
"access to unconnected input slot (operator())");
218 std::ostringstream err;
219 err <<
"pos out of range: pos = " << pos;
221 throw std::out_of_range(err.str());
224 typename std::set<AbstractSlot<T>*>::const_iterator item;
226 for (
unsigned int i = 0; i < pos; i++)
228 return getDataFromOutputSlot(*item);
236 template <
typename T>
242 return getDataFromOutputSlot(outsl);
245 template <
typename T>
263 Slot::raise(
"input connection data type mismatch (dynamic cast)");
265 return outsl->operator()();
268 const std::string& config = source->
getConfig();
269 typename std::map<std::string,T>::const_iterator found;
270 found = _dataCache.find(config);
271 if (found == _dataCache.end()) {
272 Slot::raise(
"data could not be retrieved (not cached)");
274 return found->second;
277 Slot::raise(
"cannot read from output with cache type \"invalid\"");
279 Slot::raise(
"no implementation for given output slot cache type");
282 throw std::runtime_error(
283 "unexpected error in InputSlot::_getDataFromOutputSlot");
288 typename std::set<AbstractSlot<T>*>::const_iterator item;
291 const Slot* slot = *item;
298 Slot::raise(
"input connection data type mismatch (dynamic cast)");
303 const Slot* sl=
dynamic_cast<const Slot*
>(slot);
304 const std::string& config = source->
getConfig();
308 Slot::raise(
"no data manager for this slot type available");
310 _dataCache.insert(std::pair<std::string,T>(
334 data =
new T(_initVal);
348 const std::string parName =
350 if (pf.
isSet(parName)) {
351 const std::string cType = pf.
get<std::string>(parName);
352 if (cType ==
"managed") {
355 else if (cType ==
"memory") {
358 else if (cType ==
"invalid") {
362 Slot::raise(
"Invalid cache type specified in parameter file.");
369 const std::string prefix =
"selected cache type: ";
379 Slot::raise(
"no data manager for this slot type available");
388 Slot::raise(
"setCacheType: invalid cache type given");
397 Slot::raise(
"reading from uninitialized output slot");
405 "accessing uninitialized output slot, "
406 "creating default data element");
438 switch (_cacheType) {
448 Slot::raise(
"no data manager for this slot type available");
466 template <
typename T>
468 const Slot&,
const std::string&) {
Encapsulation of slot connection handling (type specific) and common code for input and output slots...
virtual const std::string & getConfig() const =0
get manager configuration string
std::set< AbstractSlot< T > * >::const_iterator begin() const
iterator to the beginning of the source list
stay in memory after execution
static DataManager< T > * getManager(const Slot &slot, const std::string &config="")
get data manager from configuration string
virtual const OutputSlotIntf * getDataSlot() const =0
Return a pointer to a real slot.
virtual std::string getType() const =0
Get slot type.
Interface for a plugin manager.
virtual Slot::CacheType getCacheType() const =0
query data cache type
Provides an interface for a plugin manager.
This class serves to store parameters used within the Charon Project.
virtual std::string getType() const
Get slot type.
interface of data management classes
void erase(std::string parameter)
Delete a parameter from the parameter list.
bool disconnect()
Remove all slot targets.
Base class for serializable objects.
void printInfo(const std::string &msg) const
print info message with slot name to sout
virtual std::set< Slot * > getTargets() const
Get pointers to the connected targets.
virtual const T & operator()() const
Call operator.
bool connected() const
Check if slot is connected.
dumped after execution, not recommended
std::vector< T > getList(std::string parameter) const
If multiple values are set, return a list containing these values.
virtual ParameteredObject * getInstance(const std::string &instanceName) const =0
Get an existing instance of a loaded plugin.
void _check() const
check for valid data pointer
virtual void finalize()
finalize slot
VirtualOutputSlot This class holds a pointer to an output if the output is CACHE_MEM, otherwise it loads a config string from a given parameterfile.
ParameteredObject & getParent()
get parent object
Declaration of the base class ParameteredObject.
void setCacheType(Slot::CacheType type)
change data cache type
virtual std::string guessType() const
Try to guess slot type.
virtual T getData()=0
read data
virtual ~OutputSlot()
initialize data element
std::string getType() const
overloaded getType
void setCacheType(Slot::CacheType type)
set the cache type of _slot
virtual std::string getConfig() const =0
get configuration string
virtual bool _addTarget(Slot *target)
Add slot target.
void set(std::string parameter, const T &value=T())
Set a parameter to the given single value.
abstract interface class for output slots
virtual void load(const ParameterFile &pf, const PluginManagerInterface *man)
Load slot connections.
bool _multiSlot
flag to mark this slot as a multislot, that can have multiple sources/targets.
T get(std::string parameter) const
Get the value of a specified parameter.
bool isSet(std::string parameter) const
Check if a givem parameter has already been set.
virtual void prepare()
prepare slot
virtual bool _removeTarget(Slot *target)
Remove slot target.
CacheType
slot data cache type
OutputSlot(const T &initval=T())
Create new output slot.
Slot * getSlot(const std::string &slotName) const
Get pointer to some slot (by name)
virtual T & operator=(const T &B)
data assignment operator
virtual void setData(const T &data)=0
write data
std::string _type
Slot type.
charon_core_DLL_PUBLIC std::string type(const std::string &typeInfo)
Get type representation.
Commom properties of slot objects.
std::set< AbstractSlot< T > * >::const_iterator end() const
iterator to the end of the source list
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
std::string _name
Slot name.
const std::string & getName() const
instance name
virtual void save(ParameterFile &pf) const
Save slot connections This function disconnects already established connections in the parameterFile ...
virtual void save(ParameterFile &pf) const
Save slot connections This function disconnects already established connections in the parameterFile ...
void printError(const std::string &msg) const
print error with slot name and type info to sout
void _prepare()
create data element, if needed
virtual void prepare()
prepare slot
cached on disk after execution, save memory
ParameteredObject * _parent
Pointer to parent object.
bool connect(Slot &target)
Connect with given slot.
virtual std::string getType() const =0
get the type