Hedgehog  3.1.0
A library to generate hybrid pipeline workflow systems
Loading...
Searching...
No Matches
type_nodes_map_array.h
Go to the documentation of this file.
1
2// NIST-developed software is provided by NIST as a public service. You may use, copy and distribute copies of the
3// software in any medium, provided that you keep intact this entire notice. You may improve, modify and create
4// derivative works of the software or any portion of the software, and you may copy and distribute such modifications
5// or works. Modified works should carry a notice stating that you changed the software and should note the date and
6// nature of any such change. Please explicitly acknowledge the National Institute of Standards and Technology as the
7// source of the software. NIST-developed software is expressly provided "AS IS." NIST MAKES NO WARRANTY OF ANY KIND,
8// EXPRESS, IMPLIED, IN FACT OR ARISING BY OPERATION OF LAW, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTY OF
9// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT AND DATA ACCURACY. NIST NEITHER REPRESENTS NOR
10// WARRANTS THAT THE OPERATION OF THE SOFTWARE WILL BE UNINTERRUPTED OR ERROR-FREE, OR THAT ANY DEFECTS WILL BE
11// CORRECTED. NIST DOES NOT WARRANT OR MAKE ANY REPRESENTATIONS REGARDING THE USE OF THE SOFTWARE OR THE RESULTS
12// THEREOF, INCLUDING BUT NOT LIMITED TO THE CORRECTNESS, ACCURACY, RELIABILITY, OR USEFULNESS OF THE SOFTWARE. You
13// are solely responsible for determining the appropriateness of using and distributing the software and you assume
14// all risks associated with its use, including but not limited to the risks and costs of program errors, compliance
15// with applicable laws, damage to or loss of data, programs or equipment, and the unavailability or interruption of
16// operation. This software is not intended to be used in any situation where a failure could cause risk of injury or
17// damage to property. The software developed by NIST employees is not subject to copyright protection within the
18// United States.
19
20#ifndef HEDGEHOG_TYPE_NODES_MAP_ARRAY_H_
21#define HEDGEHOG_TYPE_NODES_MAP_ARRAY_H_
22#ifdef HH_ENABLE_HH_CX
23
24
25#include <array>
26#include <cstdlib>
27#include <ostream>
28#include <map>
29#include <vector>
30
32namespace hh_cx {
34namespace tool {
35
41template<size_t NbTypes, size_t MaxSizeTypeName, size_t MaxNumberNodes, size_t MaxSizeNodeName>
42class TypeNodesMapArray {
43 std::array<std::array<char, MaxSizeTypeName>, NbTypes> types_{};
44 std::array<std::array<std::array<char, MaxSizeNodeName>, MaxNumberNodes>, NbTypes> nodes_{};
45 public:
47 constexpr TypeNodesMapArray() = default;
49 constexpr virtual ~TypeNodesMapArray() = default;
50
53 constexpr std::array<std::array<char, MaxSizeTypeName>, NbTypes> &types() { return types_; }
54
57 constexpr std::array<std::array<std::array<char, MaxSizeNodeName>, MaxNumberNodes>, NbTypes> &nodes() {
58 return nodes_;
59 }
60
63 [[nodiscard]] std::map<std::string, std::vector<std::string>> mapNodeNameToTypeNames() const{
64 std::map<std::string, std::vector<std::string>> map{};
65
66 for (size_t typeId = 0; typeId < types_.size(); ++typeId) {
67 auto typeName = std::string(types_.at(typeId).data());
68 for (auto const &nameArray : nodes_.at(typeId)) {
69 auto const &nodeName = std::string(nameArray.data());
70 if (!nodeName.empty()) {
71 if (map.count(nodeName)) { map.at(nodeName).push_back(typeName); }
72 else { map.insert({nodeName, {typeName}}); }
73 }
74 }
75 }
76 return map;
77 }
78
79};
80}
81}
82#endif //HH_ENABLE_HH_CX
83#endif //HEDGEHOG_TYPE_NODES_MAP_ARRAY_H_