Hedgehog  3.1.0
A library to generate hybrid pipeline workflow systems
Loading...
Searching...
No Matches
node_abstraction.h
Go to the documentation of this file.
1// NIST-developed software is provided by NIST as a public service. You may use, copy and distribute copies of the
2// software in any medium, provided that you keep intact this entire notice. You may improve, modify and create
3// derivative works of the software or any portion of the software, and you may copy and distribute such modifications
4// or works. Modified works should carry a notice stating that you changed the software and should note the date and
5// nature of any such change. Please explicitly acknowledge the National Institute of Standards and Technology as the
6// source of the software. NIST-developed software is expressly provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND,
7// EXPRESS, IMPLIED, IN FACT OR ARISING BY OPERATION OF LAW, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
8// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT AND DATA ACCURACY. NIST NEITHER REPRESENTS NOR
9// WARRANTS THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR-FREE, OR THAT ANY DEFECTS WILL BE
10// CORRECTED. NIST DOES NOT WARRANT OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF THE SOFTWARE OR THE RESULTS
11// THEREOF, INCLUDING BUT NOT LIMITED TO THE CORRECTNESS, ACCURACY, RELIABILITY, OR USEFULNESS OF THE SOFTWARE. You
12// are solely responsible for determining the appropriateness of using and distributing the software and you assume
13// all risks associated with its use, including but not limited to the risks and costs of program errors, compliance
14// with applicable laws, damage to or loss of data, programs or equipment, and the unavailability or interruption of
15// operation. This software is not intended to be used in any situation where a failure could cause risk of injury or
16// damage to property. The software developed by NIST employees is not subject to copyright protection within the
17// United States.
18
19
20
21#ifndef HEDGEHOG_NODE_ABSTRACTION_H
22#define HEDGEHOG_NODE_ABSTRACTION_H
23
24#include <cstddef>
25#include <cassert>
26#include <string>
27#include <chrono>
28#include <ostream>
29#include <map>
30#include <utility>
31#include <vector>
32#include <sstream>
33//#include "graph_node_abstraction.h"
34
36namespace hh {
37
38#ifndef DOXYGEN_SHOULD_SKIP_THIS
40namespace behavior {
42class Node;
43}
44#endif //DOXYGEN_SHOULD_SKIP_THIS
45
46
48namespace core {
49
51namespace abstraction {
52
53#ifndef DOXYGEN_SHOULD_SKIP_THIS
54
56class GraphNodeAbstraction;
57
58#endif //DOXYGEN_SHOULD_SKIP_THIS
59
62 private:
63 std::string const name_;
64 bool isRegistered_ = false;
65
67 std::chrono::nanoseconds executionDuration_ = std::chrono::nanoseconds::zero();
68
69 std::chrono::time_point<std::chrono::system_clock>
70 startExecutionTimeStamp_ = std::chrono::system_clock::now();
71
72 public:
75 explicit NodeAbstraction(std::string name) : name_(std::move(name)) {}
76
78 virtual ~NodeAbstraction() = default;
79
82 [[nodiscard]] std::string const &name() const { return name_; }
83
86 [[nodiscard]] virtual std::string id() const {
87 std::ostringstream oss;
88 oss << "x" << this;
89 return oss.str();
90 }
91
94 [[nodiscard]] bool isRegistered() const { return isRegistered_; }
95
96
99 [[nodiscard]] GraphNodeAbstraction *belongingGraph() const { return belongingGraph_; }
100
103 [[nodiscard]] virtual int deviceId() const { return ((NodeAbstraction *) this->belongingGraph())->deviceId(); };
104
107 [[nodiscard]] virtual size_t graphId() const { return ((NodeAbstraction *) this->belongingGraph())->graphId(); };
108
111 [[nodiscard]] std::chrono::nanoseconds const &executionDuration() const { return executionDuration_; }
112
115 [[nodiscard]] std::chrono::time_point<std::chrono::system_clock> const &startExecutionTimeStamp() const {
117 }
118
121 void startExecutionTimeStamp(std::chrono::time_point<std::chrono::system_clock> const &startExecutionTimeStamp) {
123 }
124
127 void incrementExecutionDuration(std::chrono::nanoseconds const &exec) { this->executionDuration_ += exec; }
128
132 assert(isRegistered_ == false);
134 isRegistered_ = true;
135 }
136
139 [[nodiscard]] virtual std::vector<std::pair<std::string const, std::string const>> ids() const = 0;
140
143 [[nodiscard]] virtual behavior::Node * node() const = 0;
144};
145}
146}
147}
148#endif //HEDGEHOG_NODE_ABSTRACTION_H
Hedgehog main namespace.
Behavior abstraction for the base node.
Definition: node.h:32
virtual std::string id() const
Core's id ('x' + address of abstraction) as string.
virtual std::vector< std::pair< std::string const, std::string const > > ids() const =0
Node ids [nodeId, nodeGroupId] accessor.
std::chrono::nanoseconds executionDuration_
Node execution duration.
virtual void registerNode(GraphNodeAbstraction *belongingGraph)
Register node to the given graph.
std::chrono::time_point< std::chrono::system_clock > const & startExecutionTimeStamp() const
Accessor to the starting execution timestamp.
NodeAbstraction(std::string name)
Core node constructor using the core's name.
std::string const name_
Name of the core.
virtual ~NodeAbstraction()=default
DEfault destructor.
std::chrono::time_point< std::chrono::system_clock > startExecutionTimeStamp_
Node begin execution timestamp.
virtual size_t graphId() const
Get the graph identifier (got from belonging graph)
bool isRegistered() const
Accessor to registration flag.
virtual behavior::Node * node() const =0
Node accessor.
GraphNodeAbstraction * belongingGraph_
Graph holding this node.
void incrementExecutionDuration(std::chrono::nanoseconds const &exec)
Increment execution duration.
std::chrono::nanoseconds const & executionDuration() const
Execution duration.
GraphNodeAbstraction * belongingGraph() const
Belonging graph accessor.
std::string const & name() const
Accessor to the core's name.
void startExecutionTimeStamp(std::chrono::time_point< std::chrono::system_clock > const &startExecutionTimeStamp)
Setter to the starting execution timestamp.
virtual int deviceId() const
Get the device identifier (got from belonging graph)
bool isRegistered_
Is registered into a graph.