#ifndef COMDEL_VALIDATOR_H #define COMDEL_VALIDATOR_H #include "instance.h" #include "schema.h" #include "library.h" namespace domain { struct ValidationError { ComponentInstance *instance; InstanceAttribute *attribute; Action::ActionType type; std::string message; ValidationError(Action::ActionType type, std::string message): instance(nullptr), attribute(nullptr), type(type), message(message) {} ValidationError(ComponentInstance* instance, InstanceAttribute* attribute, Action::ActionType type, std::string message): instance(instance), attribute(attribute), type(type), message(message) {} }; struct ValidationContext { ComponentInstance *instance; InstanceAttribute *attribute; std::map addressSpaces; std::map attributes; std::map map(); }; class ComdelValidator { public: std::vector validateSchema(Schema &schema, ValidationContext context); std::vector validateComponent(ComponentInstance *instance, ValidationContext context); std::vector validateAttribute(InstanceAttribute *attribute, ValidationContext context); std::optional validateRule(Rule rule, ValidationContext context); std::vector validateMemoryReferences(Schema &schema, Library &library, ValidationContext context); std::vector validateInstanceNames(Schema &schema, Library &library, ValidationContext context); std::vector validateInstanceCount(Schema &schema, Library &library, ValidationContext context); std::vector validatePinConnections(Schema &schema, Library &library, ValidationContext context); ComdelValidator(std::vector validators); private: std::map validators; bool connectionExists(Schema &schema, shared_ptr &component, Pin &pin); }; } #endif //COMDEL_VALIDATOR_H