dir structure changed
This commit is contained in:
9
src/system/connect.cpp
Normal file
9
src/system/connect.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "connect.hpp"
|
||||
|
||||
Connection::Connection(std::string name) : SystemElement(name) {
|
||||
|
||||
};
|
||||
|
||||
Connections::Connections(void): SystemElementContainer<Connection>("connections") {}
|
||||
|
||||
Connections::Connections(std::vector<Connection> conns): SystemElementContainer<Connection>("connections", conns) {}
|
||||
19
src/system/connect.hpp
Normal file
19
src/system/connect.hpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef _CONNECT_HPP_
|
||||
#define _CONNECT_HPP_
|
||||
|
||||
#include "syselmts.hpp"
|
||||
|
||||
class Connection : public SystemElement
|
||||
{
|
||||
public:
|
||||
Connection(std::string name);
|
||||
};
|
||||
|
||||
class Connections : public SystemElementContainer<Connection>
|
||||
{
|
||||
public:
|
||||
Connections(void);
|
||||
Connections(std::vector<Connection> connections);
|
||||
};
|
||||
|
||||
#endif // _CONNECT_HPP_
|
||||
9
src/system/modules.cpp
Normal file
9
src/system/modules.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "modules.hpp"
|
||||
|
||||
Module::Module(std::string name) : SystemElement(name) {
|
||||
|
||||
};
|
||||
|
||||
Modules::Modules(void): SystemElementContainer<Module>("modules") {}
|
||||
|
||||
Modules::Modules(std::vector<Module> modules): SystemElementContainer<Module>("modules", modules) {}
|
||||
19
src/system/modules.hpp
Normal file
19
src/system/modules.hpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef _PINS_HPP_
|
||||
#define _PINS_HPP_
|
||||
|
||||
#include "syselmts.hpp"
|
||||
|
||||
class Module : public SystemElement
|
||||
{
|
||||
public:
|
||||
Module(std::string name);
|
||||
};
|
||||
|
||||
class Modules : public SystemElementContainer<Module>
|
||||
{
|
||||
public:
|
||||
Modules(void);
|
||||
Modules(std::vector<Module> pins);
|
||||
};
|
||||
|
||||
#endif // _PINS_HPP_
|
||||
9
src/system/parts.cpp
Normal file
9
src/system/parts.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "parts.hpp"
|
||||
|
||||
Part::Part(std::string name) : SystemElement(name) {
|
||||
|
||||
};
|
||||
|
||||
Parts::Parts(void): SystemElementContainer<Part>("parts") {}
|
||||
|
||||
Parts::Parts(std::vector<Part> parts): SystemElementContainer<Part>("parts", parts) {}
|
||||
19
src/system/parts.hpp
Normal file
19
src/system/parts.hpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef _PARTS_HPP_
|
||||
#define _PARTS_HPP_
|
||||
|
||||
#include "syselmts.hpp"
|
||||
|
||||
class Part : public SystemElement
|
||||
{
|
||||
public:
|
||||
Part(std::string name);
|
||||
};
|
||||
|
||||
class Parts : public SystemElementContainer<Part>
|
||||
{
|
||||
public:
|
||||
Parts(void);
|
||||
Parts(std::vector<Part> parts);
|
||||
};
|
||||
|
||||
#endif // _PARTS_HPP_
|
||||
9
src/system/pins.cpp
Normal file
9
src/system/pins.cpp
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "pins.hpp"
|
||||
|
||||
Pin::Pin(std::string name) : SystemElement(name) {
|
||||
|
||||
};
|
||||
|
||||
Pins::Pins(void): SystemElementContainer<Pin>("pins") {}
|
||||
|
||||
Pins::Pins(std::vector<Pin> pins): SystemElementContainer<Pin>("pins", pins) {}
|
||||
19
src/system/pins.hpp
Normal file
19
src/system/pins.hpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef _PINS_HPP_
|
||||
#define _PINS_HPP_
|
||||
|
||||
#include "syselmts.hpp"
|
||||
|
||||
class Pin : public SystemElement
|
||||
{
|
||||
public:
|
||||
Pin(std::string name);
|
||||
};
|
||||
|
||||
class Pins : public SystemElementContainer<Pin>
|
||||
{
|
||||
public:
|
||||
Pins(void);
|
||||
Pins(std::vector<Pin> pins);
|
||||
};
|
||||
|
||||
#endif // _PINS_HPP_
|
||||
11
src/system/signals.cpp
Normal file
11
src/system/signals.cpp
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
#include "signals.hpp"
|
||||
|
||||
Signal::Signal(std::string name) : SystemElement(name) {
|
||||
|
||||
};
|
||||
|
||||
Signals::Signals(void): SystemElementContainer<Signal>("signals") {}
|
||||
|
||||
Signals::Signals(std::vector<Signal> signals): SystemElementContainer<Signal>("signals", signals) {}
|
||||
|
||||
19
src/system/signals.hpp
Normal file
19
src/system/signals.hpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#ifndef _SIGNALS_HPP_
|
||||
#define _SIGNALS_HPP_
|
||||
|
||||
#include "syselmts.hpp"
|
||||
|
||||
class Signal : public SystemElement
|
||||
{
|
||||
public:
|
||||
Signal(std::string name);
|
||||
};
|
||||
|
||||
class Signals : public SystemElementContainer<Signal>
|
||||
{
|
||||
public:
|
||||
Signals(void);
|
||||
Signals(std::vector<Signal> signals);
|
||||
};
|
||||
|
||||
#endif // _SIGNALS_HPP_
|
||||
68
src/system/syselmts.hpp
Normal file
68
src/system/syselmts.hpp
Normal file
@@ -0,0 +1,68 @@
|
||||
#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) {};
|
||||
SystemElementContainer(std::string name, std::vector<T> elements) : SystemElement(name)
|
||||
{
|
||||
add(elements);
|
||||
}
|
||||
void add(T element)
|
||||
{
|
||||
if ("" == element.name)
|
||||
{
|
||||
throw std::runtime_error("System elements with empty names are forbidden");
|
||||
}
|
||||
if (name_exists(element.name))
|
||||
{
|
||||
throw std::runtime_error("System elements of same names are forbidden");
|
||||
}
|
||||
content.insert({element.name, element});
|
||||
}
|
||||
void add(std::vector<T> elements)
|
||||
{
|
||||
for (auto &element : elements)
|
||||
{
|
||||
add(element);
|
||||
}
|
||||
}
|
||||
T *get(std::string name)
|
||||
{
|
||||
auto it = content.find(name);
|
||||
if (it != content.end())
|
||||
{
|
||||
return &it->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
18
src/system/system.cpp
Normal file
18
src/system/system.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
#include "system.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
System::System(void): mods(nullptr), conns(nullptr) {
|
||||
mods = new Modules();
|
||||
conns = new Connections();
|
||||
}
|
||||
|
||||
System::~System() {
|
||||
delete mods;
|
||||
delete conns;
|
||||
}
|
||||
|
||||
void System::add_mentor(ifstream lines) {
|
||||
|
||||
}
|
||||
18
src/system/system.hpp
Normal file
18
src/system/system.hpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef _SYSTEM_HPP_
|
||||
#define _SYSTEM_HPP_
|
||||
|
||||
#include "connect.hpp"
|
||||
#include "modules.hpp"
|
||||
|
||||
|
||||
class System
|
||||
{
|
||||
Modules *mods;
|
||||
Connections *conns;
|
||||
|
||||
public:
|
||||
System(void);
|
||||
void add_mentor(std::ifstream lines);
|
||||
};
|
||||
|
||||
#endif // _SYSTEM_HPP_
|
||||
0
src/system/transform.cpp
Normal file
0
src/system/transform.cpp
Normal file
0
src/system/transform.hpp
Normal file
0
src/system/transform.hpp
Normal file
Reference in New Issue
Block a user