schema_editor/application.h

61 lines
1.9 KiB
C
Raw Normal View History

//
// Created by bbr on 27.05.22..
//
#ifndef SCHEMEEDITOR_APPLICATION_H
#define SCHEMEEDITOR_APPLICATION_H
#include <set>
#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;
std::vector<domain::FunctionValidator*> validators = domain::getSupportedValidators();
std::string generateName(std::set<std::string>& names, std::string instanceName);
domain::ComponentInstance *findComponentByName(std::string componentName);
domain::BusInstance *findBusByName(std::string busName);
public:
std::optional<domain::Library> getLibrary();
domain::Schema* getSchema();
void clear();
bool loadLibrary(std::string& filename, std::ostream& errorOutput);
std::pair<bool, std::vector<domain::ValidationError>> 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);
std::shared_ptr<domain::ComponentInstance> addComponent(domain::Component component, std::vector<domain::InstanceAttribute> attributes, int x, int y);
bool removeComponent(std::string component);
std::shared_ptr<domain::BusInstance> addBus(domain::Bus bus, int x, int y);
bool removeBus(std::string bus);
static bool hasErrors(std::vector<domain::ValidationError> empty);
~Application() = default;
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);
};
#endif //SCHEMEEDITOR_APPLICATION_H