Initial commit
This commit is contained in:
0
src/connect.cpp
Normal file
0
src/connect.cpp
Normal file
0
src/connect.hpp
Normal file
0
src/connect.hpp
Normal file
4
src/main.cpp
Normal file
4
src/main.cpp
Normal file
@@ -0,0 +1,4 @@
|
||||
|
||||
int main() {
|
||||
|
||||
};
|
||||
0
src/parts.cpp
Normal file
0
src/parts.cpp
Normal file
11
src/signals.cpp
Normal file
11
src/signals.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
#include "signals.hpp"
|
||||
|
||||
Signal::Signal(std::string name) : SystemElement(name) {
|
||||
|
||||
};
|
||||
|
||||
Signals::Signals(std::vector<Signal> signals): SystemElementContainer<Signal>("signals") {
|
||||
add(signals);
|
||||
}
|
||||
|
||||
9
src/signals.hpp
Normal file
9
src/signals.hpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "syselmts.hpp"
|
||||
|
||||
class Signal: public SystemElement {
|
||||
Signal(std::string name);
|
||||
};
|
||||
|
||||
class Signals: public SystemElementContainer<Signal> {
|
||||
Signals(std::vector<Signal> signals);
|
||||
};
|
||||
55
src/syselmts.hpp
Normal file
55
src/syselmts.hpp
Normal file
@@ -0,0 +1,55 @@
|
||||
|
||||
#ifndef _SYSELEMENTS_HPP_
|
||||
#define _SYSELEMENTS_HPP_
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <unordered_map>
|
||||
#include <stdexcept>
|
||||
|
||||
class SystemElement
|
||||
{
|
||||
public:
|
||||
std::string name;
|
||||
SystemElement(std::string name): name(name) {};
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class SystemElementContainer : public SystemElement
|
||||
{
|
||||
private:
|
||||
static_assert(std::is_base_of<SystemElement, T>::value, "T shall be a system element descendant !");
|
||||
unsigned int iter_count;
|
||||
std::unordered_map<std::string, T> content;
|
||||
|
||||
bool name_exists(std::string name) {
|
||||
return get(name) != nullptr;
|
||||
}
|
||||
|
||||
public:
|
||||
SystemElementContainer(std::string name) : SystemElement(name) {};
|
||||
void add(const T element) {
|
||||
if ("" == element.name) {
|
||||
throw std::runtime_error("Elements with empty names are forbidden");
|
||||
}
|
||||
if name_exists(element.name) {
|
||||
throw std::runtime_error("Elements of same names are forbidden");
|
||||
}
|
||||
content[element.name] = element;
|
||||
}
|
||||
void add(const std::vector<T> elements) {
|
||||
for (const auto& element: elements) {
|
||||
|
||||
}
|
||||
}
|
||||
T* get(std::string name) {
|
||||
auto it = content.find(name);
|
||||
if (it != content.end()) {
|
||||
return &it->second;
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
0
src/system.cpp
Normal file
0
src/system.cpp
Normal file
0
src/system.hpp
Normal file
0
src/system.hpp
Normal file
0
src/transform.cpp
Normal file
0
src/transform.cpp
Normal file
0
src/transform.hpp
Normal file
0
src/transform.hpp
Normal file
Reference in New Issue
Block a user