NRP Core  1.4.1
status_function.h
Go to the documentation of this file.
1 /* * NRP Core - Backend infrastructure to synchronize simulations
2  *
3  * Copyright 2020-2023 NRP Team
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * This project has received funding from the European Union’s Horizon 2020
18  * Framework Programme for Research and Innovation under the Specific Grant
19  * Agreement No. 945539 (Human Brain Project SGA3).
20  */
21 
22 #ifndef STATUS_FUNCTION_H
23 #define STATUS_FUNCTION_H
24 
26 
29 
30 #include <string>
31 #include <boost/python.hpp>
32 
38  public PtrTemplates<StatusFunction>
39 {
40  public:
50  virtual ~StatusFunction() override = default;
51 
58  const std::string &linkedEngineName() const override final;
59 
66  bool isPreprocessing() const override final;
67 
77  TransceiverDataPackInterface::shared_ptr pySetup(boost::python::object statusFunction);
78 
85  boost::python::object runTf(boost::python::tuple &args, boost::python::dict &kwargs, datapacks_set_t dataPacks) override;
86 
87  protected:
89 
91 
92  private:
93 
94  std::string name = "";
98  boost::python::object _function;
99 
103  TransceiverDataPackInterface::shared_ptr *_tfInterpreterRegistryPtr = nullptr;
104 
109  TransceiverDataPackInterface::shared_ptr *getTFInterpreterRegistry() override final;
110 };
111 
112 #endif // STATUS_FUNCTION_H
113 
114 // EOF
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
engine_client_interface.h
datapack_identifiers_set_t
std::set< DataPackIdentifier > datapack_identifiers_set_t
Definition: datapack_interface.h:221
function_manager.h
PtrTemplates
Definition: ptr_templates.h:28
TransceiverDataPackInterface
Base of TF Decorators.
Definition: transceiver_datapack_interface.h:40
StatusFunction::linkedEngineName
const std::string & linkedEngineName() const override final
Returns an empty string.
Definition: status_function.cpp:41
StatusFunction::getRequestedDataPackIDs
datapack_identifiers_set_t getRequestedDataPackIDs() const override
Returns datapack IDs of this DataPack that should be requested from the engines. TODO: Make protected...
Definition: status_function.cpp:58
StatusFunction::~StatusFunction
virtual ~StatusFunction() override=default
StatusFunction::pySetup
TransceiverDataPackInterface::shared_ptr pySetup(boost::python::object statusFunction)
Performs actual initialization of the object.
Definition: status_function.cpp:28
PtrTemplates< TransceiverDataPackInterface >::shared_ptr
std::shared_ptr< TransceiverDataPackInterface > shared_ptr
Definition: ptr_templates.h:31
StatusFunction::isPreprocessing
bool isPreprocessing() const override final
Returns false.
Definition: status_function.cpp:46
StatusFunction::runTf
boost::python::object runTf(boost::python::tuple &args, boost::python::dict &kwargs, datapacks_set_t dataPacks) override
Runs the status function.
Definition: status_function.cpp:51
StatusFunction
Holds a single Python function created with StatusFunction decorator.
Definition: status_function.h:36
StatusFunction::updateRequestedDataPackIDs
datapack_identifiers_set_t updateRequestedDataPackIDs(datapack_identifiers_set_t &&datapackIDs) const override
Appends its own datapack requests onto datapackIDs. Uses getRequestedDataPackIDs to check which IDs a...
Definition: status_function.cpp:63
transceiver_datapack_interface.h
StatusFunction::StatusFunction
StatusFunction()
Constructs a status function object.
Definition: status_function.cpp:25