NRP Core  1.4.1
simulation_iteration_decorator.h
Go to the documentation of this file.
1 /*
2  * NRP Core - Backend infrastructure to synchronize simulations
3  *
4  * Copyright 2020-2023 NRP Team
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * This project has received funding from the European Union’s Horizon 2020
19  * Framework Programme for Research and Innovation under the Specific Grant
20  * Agreement No. 945539 (Human Brain Project SGA3).
21  */
22 
23 #ifndef SIMULATION_ITERATION_DECORATOR_H
24 #define SIMULATION_ITERATION_DECORATOR_H
25 
28 
29 #include <string>
30 #include <boost/python.hpp>
31 
37 {
38  public:
39  SimulationIterationDecorator(const std::string &keyword)
40  : _keyword(keyword)
41  {
42 
43  }
44 
45  boost::python::object runTf(boost::python::tuple &args, boost::python::dict &kwargs, datapacks_set_t dataPacks) override
46  {
47  kwargs[this->_keyword] = this->getFunctionManager()->getSimulationIteration();
48 
49  return TransceiverDataPackInterface::runTf(args, kwargs, dataPacks);
50  }
51 
52  private:
53 
54  std::string _keyword;
55 };
56 
57 #endif // SIMULATION_ITERATION_DECORATOR_H
58 
59 // EOF
TransceiverDataPackInterface::getFunctionManager
static const FunctionManager * getFunctionManager()
Definition: transceiver_datapack_interface.h:103
datapacks_set_t
std::set< std::shared_ptr< const DataPackInterface >, DataPackPointerComparator > datapacks_set_t
Definition: datapack_interface.h:219
python_json_engine.args
Namespace args
Definition: python_json_engine.py:196
TransceiverDataPackInterface::runTf
virtual boost::python::object runTf(boost::python::tuple &args, boost::python::dict &kwargs, datapacks_set_t dataPacks)
Execute Transceiver Function. Base class will simply call runTf on _function.
Definition: transceiver_datapack_interface.cpp:37
function_manager.h
SimulationIterationDecorator::runTf
boost::python::object runTf(boost::python::tuple &args, boost::python::dict &kwargs, datapacks_set_t dataPacks) override
Execute Transceiver Function. Base class will simply call runTf on _function.
Definition: simulation_iteration_decorator.h:45
SimulationIterationDecorator::SimulationIterationDecorator
SimulationIterationDecorator(const std::string &keyword)
Definition: simulation_iteration_decorator.h:39
TransceiverDataPackInterface
Base of TF Decorators.
Definition: transceiver_datapack_interface.h:40
SimulationIterationDecorator
Class for retrieving simulation iteration in Functions, mapped to SimulationIteration python decorato...
Definition: simulation_iteration_decorator.h:35
transceiver_datapack_interface.h
FunctionManager::getSimulationIteration
unsigned long getSimulationIteration() const
Returns simulation iteration number stored by the manager.
Definition: function_manager.cpp:401