changes
This commit is contained in:
@@ -18,6 +18,7 @@ add_executable(
|
|||||||
)
|
)
|
||||||
|
|
||||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
|
||||||
|
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
|
||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
essim PRIVATE ${LIB_FTXUI}
|
essim PRIVATE ${LIB_FTXUI}
|
||||||
|
|||||||
@@ -2,29 +2,28 @@
|
|||||||
#define _IMPORT_BASE_HPP_
|
#define _IMPORT_BASE_HPP_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
#include "connect.hpp"
|
#include "system/connect.hpp"
|
||||||
#include "modules.hpp"
|
#include "system/parts.hpp"
|
||||||
|
|
||||||
class ImportBase
|
class ImportBase
|
||||||
{
|
{
|
||||||
Connections *connects;
|
protected:
|
||||||
Modules *mods;
|
Parts *prts;
|
||||||
|
virtual void parse(std::fstream lines) = 0;
|
||||||
public:
|
public:
|
||||||
ImportBase()
|
ImportBase()
|
||||||
{
|
{
|
||||||
connects = new Connections();
|
prts = new Parts();
|
||||||
mods = new Modules();
|
|
||||||
}
|
}
|
||||||
virtual void load(std::string file_name) = 0;
|
void load(std::string file_name) {
|
||||||
Connections *connections()
|
std::ifstream file(file_name);
|
||||||
|
|
||||||
|
};
|
||||||
|
Parts *parts()
|
||||||
{
|
{
|
||||||
return connects;
|
return prts;
|
||||||
}
|
|
||||||
Modules *modules()
|
|
||||||
{
|
|
||||||
return mods;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,67 @@
|
|||||||
|
|
||||||
#include "import_mentor.hpp"
|
#include "import_mentor.hpp"
|
||||||
|
#include "system/parts.hpp"
|
||||||
|
#include "system/pins.hpp"
|
||||||
|
|
||||||
ImportMentor::ImportMentor() {
|
#include <string>
|
||||||
|
#include <regex>
|
||||||
|
|
||||||
|
enum class State {
|
||||||
|
NO_PART,
|
||||||
|
IS_PART,
|
||||||
|
};
|
||||||
|
|
||||||
|
ImportMentor::ImportMentor(): ImportBase() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ImportMentor::~ImportMentor() {
|
ImportMentor::~ImportMentor() {
|
||||||
|
ImportBase::~ImportBase();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImportMentor::load(std::string filename) {
|
void ImportMentor::parse(std::fstream lines) {
|
||||||
|
std::string line;
|
||||||
|
auto state = State::NO_PART;
|
||||||
|
const std::regex name_regex("\\'([^\\']*)\\'");
|
||||||
|
const std::regex part_regex("^COMP:");
|
||||||
|
const std::regex pin_regex("^Explicit Pin:");
|
||||||
|
|
||||||
|
while (std::getline(lines, line))
|
||||||
|
{
|
||||||
|
Part *prt = nullptr;
|
||||||
|
std::smatch name_match;
|
||||||
|
bool is_name_match = std::regex_match(line, name_match, part_regex);
|
||||||
|
bool is_part_match = std::regex_match(line, part_regex);
|
||||||
|
bool is_pin_match = std::regex_match(line, pin_regex);
|
||||||
|
switch (state)
|
||||||
|
{
|
||||||
|
case State::NO_PART:
|
||||||
|
if (is_part_match) {
|
||||||
|
if (is_name_match) {
|
||||||
|
prt = new Part(name_match[0]);
|
||||||
|
state = State::IS_PART;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if (is_part_match) {
|
||||||
|
if (is_name_match) {
|
||||||
|
prts->add(*prt);
|
||||||
|
prt = new Part(name_match[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (is_pin_match)
|
||||||
|
{
|
||||||
|
if (is_name_match) {
|
||||||
|
auto pin = new Pin(name_match[0]);
|
||||||
|
prt->add(*pin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (state == State::IS_PART) {
|
||||||
|
prts->add(*prt);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -7,10 +7,10 @@
|
|||||||
|
|
||||||
class ImportMentor : public ImportBase
|
class ImportMentor : public ImportBase
|
||||||
{
|
{
|
||||||
|
void parse(std::fstream lines);
|
||||||
public:
|
public:
|
||||||
ImportMentor();
|
ImportMentor();
|
||||||
~ImportMentor();
|
~ImportMentor();
|
||||||
void load(std::string file_name);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _IMPORT_MENTOR_HPP_
|
#endif // _IMPORT_MENTOR_HPP_
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
#include "signals.hpp"
|
#include "system/signals.hpp"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
#include "connect.hpp"
|
#include "connect.hpp"
|
||||||
|
|
||||||
Connection::Connection(std::string name) : SystemElement(name) {
|
Connection::Connection(std::string name) : SystemElement(name) {};
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
Connections::Connections(void): SystemElementContainer<Connection>("connections") {}
|
Connections::Connections(void): SystemElementContainer<Connection>("connections") {}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
#include "modules.hpp"
|
#include "modules.hpp"
|
||||||
|
|
||||||
Module::Module(std::string name) : SystemElement(name) {
|
Module::Module(std::string name) : SystemElementContainer<Part>(name) {};
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
Modules::Modules(void): SystemElementContainer<Module>("modules") {}
|
Modules::Modules(void): SystemElementContainer<Module>("modules") {}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
#ifndef _PINS_HPP_
|
#ifndef _MODULES_HPP_
|
||||||
#define _PINS_HPP_
|
#define _MODULES_HPP_
|
||||||
|
|
||||||
#include "syselmts.hpp"
|
#include "syselmts.hpp"
|
||||||
|
#include "parts.hpp"
|
||||||
|
|
||||||
class Module : public SystemElement
|
class Module : public SystemElementContainer<Part>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Module(std::string name);
|
Module(std::string name);
|
||||||
@@ -16,4 +17,4 @@ public:
|
|||||||
Modules(std::vector<Module> pins);
|
Modules(std::vector<Module> pins);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _PINS_HPP_
|
#endif // _MODULES_HPP_
|
||||||
@@ -1,8 +1,6 @@
|
|||||||
#include "parts.hpp"
|
#include "parts.hpp"
|
||||||
|
|
||||||
Part::Part(std::string name) : SystemElement(name) {
|
Part::Part(std::string name) : SystemElementContainer<Pin>(name) {};
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
Parts::Parts(void): SystemElementContainer<Part>("parts") {}
|
Parts::Parts(void): SystemElementContainer<Part>("parts") {}
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
#define _PARTS_HPP_
|
#define _PARTS_HPP_
|
||||||
|
|
||||||
#include "syselmts.hpp"
|
#include "syselmts.hpp"
|
||||||
|
#include "pins.hpp"
|
||||||
|
|
||||||
class Part : public SystemElement
|
class Part : public SystemElementContainer<Pin>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Part(std::string name);
|
Part(std::string name);
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
#include "pins.hpp"
|
#include "pins.hpp"
|
||||||
|
|
||||||
Pin::Pin(std::string name) : SystemElement(name) {
|
Pin::Pin(std::string name) : SystemElement(name) {};
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
Pins::Pins(void): SystemElementContainer<Pin>("pins") {}
|
Pins::Pins(void): SystemElementContainer<Pin>("pins") {}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
|
|
||||||
#include "signals.hpp"
|
#include "signals.hpp"
|
||||||
|
|
||||||
Signal::Signal(std::string name) : SystemElement(name) {
|
Signal::Signal(std::string name) : SystemElementContainer<Pin>(name) {};
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
Signals::Signals(void): SystemElementContainer<Signal>("signals") {}
|
Signals::Signals(void): SystemElementContainer<Signal>("signals") {}
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,9 @@
|
|||||||
#define _SIGNALS_HPP_
|
#define _SIGNALS_HPP_
|
||||||
|
|
||||||
#include "syselmts.hpp"
|
#include "syselmts.hpp"
|
||||||
|
#include "pins.hpp"
|
||||||
|
|
||||||
class Signal : public SystemElement
|
class Signal : public SystemElementContainer<Pin>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Signal(std::string name);
|
Signal(std::string name);
|
||||||
|
|||||||
@@ -44,6 +44,10 @@ public:
|
|||||||
}
|
}
|
||||||
content.insert({element.name, element});
|
content.insert({element.name, element});
|
||||||
}
|
}
|
||||||
|
void add(SystemElementContainer<T> elements)
|
||||||
|
{
|
||||||
|
add(elements.content);
|
||||||
|
}
|
||||||
void add(std::vector<T> elements)
|
void add(std::vector<T> elements)
|
||||||
{
|
{
|
||||||
for (auto &element : elements)
|
for (auto &element : elements)
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
|
|
||||||
#include "system.hpp"
|
#include "system.hpp"
|
||||||
|
|
||||||
using namespace std;
|
System::System(): mods(nullptr), conns(nullptr) {
|
||||||
|
|
||||||
System::System(void): mods(nullptr), conns(nullptr) {
|
|
||||||
mods = new Modules();
|
mods = new Modules();
|
||||||
conns = new Connections();
|
conns = new Connections();
|
||||||
}
|
}
|
||||||
@@ -12,7 +10,3 @@ System::~System() {
|
|||||||
delete mods;
|
delete mods;
|
||||||
delete conns;
|
delete conns;
|
||||||
}
|
}
|
||||||
|
|
||||||
void System::add_mentor(ifstream lines) {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -4,15 +4,14 @@
|
|||||||
#include "connect.hpp"
|
#include "connect.hpp"
|
||||||
#include "modules.hpp"
|
#include "modules.hpp"
|
||||||
|
|
||||||
|
|
||||||
class System
|
class System
|
||||||
{
|
{
|
||||||
Modules *mods;
|
Modules *mods;
|
||||||
Connections *conns;
|
Connections *conns;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
System(void);
|
System();
|
||||||
void add_mentor(std::ifstream lines);
|
~System();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _SYSTEM_HPP_
|
#endif // _SYSTEM_HPP_
|
||||||
Reference in New Issue
Block a user