NRP Core  1.4.1
transceiver_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 TRANSCEIVER_FUNCTION_H
23 #define TRANSCEIVER_FUNCTION_H
24 
26 
29 
30 #include <string>
31 #include <boost/python.hpp>
32 
38  public PtrTemplates<TransceiverFunction>
39 {
40  public:
46  TransceiverFunction(std::string linkedEngine, bool isPreprocessing);
47  virtual ~TransceiverFunction() override = default;
48 
49  const std::string &linkedEngineName() const override;
50 
51  bool isPreprocessing() const override;
52 
58  TransceiverDataPackInterface::shared_ptr pySetup(boost::python::object transceiverFunction);
59 
66  boost::python::object runTf(boost::python::tuple &args, boost::python::dict &kwargs, datapacks_set_t dataPacks) override;
67 
68  protected:
70 
72 
73  private:
77  boost::python::object _function;
78 
82  std::string _linkedEngine;
83 
87  bool _isPreprocessing;
88 
92  TransceiverDataPackInterface::shared_ptr *_tfInterpreterRegistryPtr = nullptr;
93 
98  TransceiverDataPackInterface::shared_ptr *getTFInterpreterRegistry() override final;
99 
103  void checkTFOutputIsCorrectOrRaise(const boost::python::object &tfOutput) const;
104 };
105 
106 #endif // TRANSCEIVER_FUNCTION_H
datapacks_set_t
std::set< std::shared_ptr< const DataPackInterface >, DataPackPointerComparator > datapacks_set_t
Definition: datapack_interface.h:219
TransceiverFunction::linkedEngineName
const std::string & linkedEngineName() const override
Get name of engine this transceiver is linked to.
Definition: transceiver_function.cpp:30
TransceiverFunction
Holds a single transfer function decorator.
Definition: transceiver_function.h:36
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
TransceiverFunction::~TransceiverFunction
virtual ~TransceiverFunction() override=default
PtrTemplates
Definition: ptr_templates.h:28
TransceiverDataPackInterface
Base of TF Decorators.
Definition: transceiver_datapack_interface.h:40
TransceiverFunction::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: transceiver_function.cpp:84
PtrTemplates< TransceiverDataPackInterface >::shared_ptr
std::shared_ptr< TransceiverDataPackInterface > shared_ptr
Definition: ptr_templates.h:31
TransceiverFunction::runTf
boost::python::object runTf(boost::python::tuple &args, boost::python::dict &kwargs, datapacks_set_t dataPacks) override
Execute the transfer function.
Definition: transceiver_function.cpp:49
TransceiverFunction::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: transceiver_function.cpp:89
TransceiverFunction::pySetup
TransceiverDataPackInterface::shared_ptr pySetup(boost::python::object transceiverFunction)
Decorator call() function. Takes the Transfer Function as a parameter. Moves this class into a shared...
Definition: transceiver_function.cpp:36
TransceiverFunction::isPreprocessing
bool isPreprocessing() const override
Indicates if this is a preprocessing function.
Definition: transceiver_function.cpp:33
TransceiverFunction::TransceiverFunction
TransceiverFunction(std::string linkedEngine, bool isPreprocessing)
Constructor.
Definition: transceiver_function.cpp:25
transceiver_datapack_interface.h