2022-05-30 21:11:06 +00:00
|
|
|
//
|
|
|
|
// Created by bbr on 27.05.22..
|
|
|
|
//
|
|
|
|
|
|
|
|
#ifndef SCHEMEEDITOR_APPLICATION_H
|
|
|
|
#define SCHEMEEDITOR_APPLICATION_H
|
|
|
|
|
|
|
|
|
2022-05-30 23:05:08 +00:00
|
|
|
#include <set>
|
2022-05-30 21:11:06 +00:00
|
|
|
#include "comdel/domain/library.h"
|
|
|
|
#include "comdel/domain/schema.h"
|
|
|
|
#include "comdel/domain/comdel_validator.h"
|
|
|
|
|
|
|
|
|
|
|
|
class Application {
|
|
|
|
private:
|
|
|
|
std::string libraryPath;
|
|
|
|
std::optional<domain::Library> library = std::nullopt;
|
|
|
|
domain::Schema* schema = nullptr;
|
2022-05-30 23:05:08 +00:00
|
|
|
std::vector<domain::FunctionValidator*> validators = domain::getSupportedValidators();
|
|
|
|
|
|
|
|
std::string generateName(std::set<std::string>& names, std::string instanceName);
|
|
|
|
|
2022-06-01 23:37:14 +00:00
|
|
|
domain::ComponentInstance *findComponentByName(std::string componentName);
|
|
|
|
domain::BusInstance *findBusByName(std::string busName);
|
|
|
|
|
2022-05-30 21:11:06 +00:00
|
|
|
public:
|
|
|
|
std::optional<domain::Library> getLibrary();
|
|
|
|
domain::Schema* getSchema();
|
|
|
|
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
bool loadLibrary(std::string& filename, std::ostream& errorOutput);
|
2022-06-01 23:37:14 +00:00
|
|
|
std::pair<bool, std::vector<domain::ValidationError>> loadSchema(std::string& filename, std::ostream& errorOutput);
|
2022-05-30 21:11:06 +00:00
|
|
|
|
|
|
|
static Application* instance();
|
|
|
|
|
|
|
|
bool generateSchema(std::ostringstream &output);
|
|
|
|
std::vector<domain::ValidationError> validateSchema();
|
|
|
|
std::vector<domain::ValidationError> generateComdel(std::ostringstream &output);
|
|
|
|
|
2022-05-30 23:05:08 +00:00
|
|
|
std::shared_ptr<domain::ComponentInstance> addComponent(domain::Component component, std::vector<domain::InstanceAttribute> attributes, int x, int y);
|
2022-06-01 23:37:14 +00:00
|
|
|
bool removeComponent(std::string component);
|
|
|
|
|
2022-05-30 23:05:08 +00:00
|
|
|
std::shared_ptr<domain::BusInstance> addBus(domain::Bus bus, int x, int y);
|
2022-06-01 23:37:14 +00:00
|
|
|
bool removeBus(std::string bus);
|
2022-05-30 23:05:08 +00:00
|
|
|
|
2022-05-30 21:11:06 +00:00
|
|
|
static bool hasErrors(std::vector<domain::ValidationError> empty);
|
|
|
|
|
|
|
|
~Application() = default;
|
2022-06-01 23:37:14 +00:00
|
|
|
|
|
|
|
void renameComponent(std::string currentName, std::string newName);
|
|
|
|
|
|
|
|
void renameBus(std::string currentName, std::string newName);
|
2022-06-09 21:42:45 +00:00
|
|
|
|
|
|
|
void removeConnection(domain::ConnectionInstance *pInstance);
|
2022-05-30 21:11:06 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //SCHEMEEDITOR_APPLICATION_H
|