30 "VirtualSlotSwitch", name,
31 "<h2>Connects its output to one of its inputs according to a "
32 "statement or inputnumber</h2><br>"
33 "Connects its output to one of its inputs according to a "
34 "statement or inputnumber."
36 statement(true,false),
37 inputnumber(true,false),output(0)
42 "statement to switch between input 0 and input 1",
46 "connects output to according input",
51 "output connected to one of the inputs",
54 ParameteredObject::_addParameter< int >(
58 ParameteredObject::_addParameter< bool >(
59 boolean_inputnumber,
"boolean_inputnumber",
60 "cast inputnumber to bool",
69 VirtualSlotSwitch::~VirtualSlotSwitch()
71 setNumberOfVirtualSlots(0);
77 raise(
"Either statement or inputnumber must be connected!");
85 if(boolean_inputnumber())
89 if(selected_in>=_virtualInputSlots.size()||selected_in<0)
91 std::stringstream msg;
92 msg<<
"Out of range: Selected input: "<<selected_in<<
". Possible range [0,"<<_virtualInputSlots.size()-1<<
"]"<<std::endl;
96 if(oldselection!=selected_in)
98 sout<<
"Switching to slot "<<selected_in<<std::endl;
101 _virtualInputSlots[oldselection]->setVirtualPartnerSlot(_virtualOutputSlots[oldselection]);
102 oldselection=selected_in;
113 raise(
"Number of inputs must be at least 2");
119 void VirtualSlotSwitch::setNumberOfVirtualSlots(
int num)
123 std::vector<VirtualOutputSlot*> tempOutputSlots;
124 std::vector<VirtualInputSlot*> tempInputSlots;
127 int nslots=std::min(num,(
int)_virtualOutputSlots.size());
128 for(
int i=0;i<nslots;i++)
130 tempInputSlots.push_back(_virtualInputSlots[i]);
131 tempOutputSlots.push_back(_virtualOutputSlots[i]);
135 for(
int i=nslots;i<num;i++)
140 tempInputSlots.push_back(in);
141 tempOutputSlots.push_back(out);
145 for(
size_t i=num;i<_virtualOutputSlots.size();i++) {
150 delete _virtualOutputSlots[i];
151 delete _virtualInputSlots[i];
155 _virtualInputSlots=tempInputSlots;
156 _virtualOutputSlots=tempOutputSlots;
159 for(
int i=nslots;i<num;i++)
162 _virtualInputSlots[i]->
getName(),
163 "Virtual Slot",_virtualInputSlots[i]->getType());
This class serves to store parameters used within the Charon Project.
forstatement_DECLDIR void destroy(ParameteredObject *b)
Deletes an instance of the plugin.
build_type
defined build type
Parameter< int > number_of_inputs
number_of_inputs
void setVirtualPartnerSlot(VirtualSlot *insl)
Set corresponding partner VirtualSlot.
SplitStream sout
Dummy instance for usage in other files (for interface too).
template_type
Integer which represents a template type.
Base class for serializable objects.
Convenience file to iclude all ParameteredObject dependencies and Template functions.
bool connected() const
Check if slot is connected.
void _setDynamic(bool v)
Specifies if the ParameteredObject is dynamic.
the object was compiled in release mode
std::string getName() const
get the Name
forstatement_DECLDIR ParameteredObject * create(const std::string &name, ParameteredObject::template_type)
Creates an instance of the plugin.
InputSlot< bool > statement
statement to switch between input 0 and input 1
std::string getType() const
overloaded getType
void _removeInputSlot(std::string name)
Remove an input slot.
void _addInputSlot(Slot &slot, const std::string &name, const std::string &doc, const std::string &type="")
These functions needs to be called by the derived class in order to register all objects which can be...
Connects its output to one of its inputs according to a statement or inputnumber. ...
virtualslotswitch_DECLDIR ParameteredObject::build_type getBuildType()
Report build configuration to prevent linking of incompatibel runtime libs.
VirtualOutputSlot output
output connected to one of the inputs
virtual void load(const ParameterFile &pf)
Load from ParameterFile.
the object was compiled in debug mode
virtual void prepareDynamicInterface(const ParameterFile &file)
prepare interface of parameters and slots
Commom properties of slot objects.
void _addOutputSlot(Slot &slot, const std::string &name, const std::string &doc, const std::string &type="")
Register output slot.
#define virtualslotswitch_DECLDIR
Not needed without MSVC.
VirtualSlotSwitch(const std::string &name="")
default constructor
const std::string & getName() const
instance name
virtual void execute()
Update object.
InputSlot< int > inputnumber
connects output to according input