MUQ  0.4.3
ConstantPiece.cpp
Go to the documentation of this file.
2 
3 using namespace muq::Modeling;
4 
5 ConstantPiece::ConstantPiece(std::vector<boost::any> const& outs) : WorkPiece(0, Types(outs)) {
6  // the outputs will not change inside evaluate so we should not clear them
7  clearOutputs = false;
8 
9  // populate the vector of outputs
10  outputs.resize(numOutputs);
11  std::copy(outs.begin(), outs.end(), outputs.begin());
12 }
13 
15  // the outputs will not change inside evaluate so we should not clear them
16  clearOutputs = false;
17 }
18 
19 void ConstantPiece::SetOutputs(std::vector<boost::any> const& outs) {
20  // clear the output types
21  outputTypes.clear();
22 
23  // set the output types
24  outputTypes = Types(Types(outs));
25 
26  // populate the vector of outputs
27  outputs.resize(outs.size());
28  std::copy(outs.begin(), outs.end(), outputs.begin());
29 }
30 
32  // clear the output types
33  outputTypes.clear();
34 
35  // clear the vector of outputs
36  outputs.clear();
37 }
38 
39 // the outputs are already set and not cleared so don't do anything
ConstantPiece()
Create a muq::Modeling::ConstantPiece with no given outputs.
void SetOutputs(ith const &in, Args... args)
Create a muq::Modeling::ConstantPiece with the outputs given indivually.
Definition: ConstantPiece.h:77
Base class for MUQ's modelling envronment.
Definition: WorkPiece.h:40
std::map< unsigned int, std::string > outputTypes
The output types.
Definition: WorkPiece.h:558
virtual void EvaluateImpl(ref_vector< boost::any > const &inputs)=0
User-implemented function that determines the behavior of this muq::Modeling::WorkPiece.
std::vector< std::string > Types(std::vector< boost::any > const &vec) const
Get the types from a vector of boost::any's.
Definition: WorkPiece.cpp:201
bool clearOutputs
Clear outputs every time Evaluate is called.
Definition: WorkPiece.h:540
int numOutputs
The number of outputs.
Definition: WorkPiece.h:504
std::vector< boost::any > outputs
The outputs.
Definition: WorkPiece.h:546
std::vector< std::reference_wrapper< const T > > ref_vector
A vector of references to something ...
Definition: WorkPiece.h:37