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-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);
|
|
|
|
bool loadSchema(std::string& filename, std::ostream& errorOutput);
|
|
|
|
|
|
|
|
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);
|
|
|
|
std::shared_ptr<domain::BusInstance> addBus(domain::Bus bus, int x, int y);
|
|
|
|
|
2022-05-30 21:11:06 +00:00
|
|
|
static bool hasErrors(std::vector<domain::ValidationError> empty);
|
|
|
|
|
|
|
|
~Application() = default;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif //SCHEMEEDITOR_APPLICATION_H
|