#ifndef DOMAIN_COMDEL_GENERATOR_H #define DOMAIN_COMDEL_GENERATOR_H #include "library.h" #include "schema.h" #include #include #include #include #include namespace domain { /** Context used for loading model */ struct ComdelContext { std::vector attributes; std::vector wires; std::string name; bool inComponent; bool inConnection; bool inSingleAutomaticConnection; ComdelContext(std::string name, bool inComponent, bool inConnection, bool inSingleAutomaticConnection); bool doesAttributeExists(std::string name, Value::ValueType type); bool doesWireExists(std::string name); }; class SchemaCreator { public: explicit SchemaCreator(std::vector validators); std::vector getErrors(); std::optional loadLibrary(LibraryNode node); Schema *loadSchema(SchemaNode node, Library &library); private: std::vector context; std::string name; std::string libraryInfo; std::string header; std::string componentDirectory; std::optional componentHeader = nullopt; std::vector addressSpaces; std::vector components; std::vector buses; std::vector connections; std::map messages; std::vector errors; std::vector validators; std::optional loadAddressSpace(AddressSpaceNode node); std::optional loadComponent(ComponentNode node); std::optional loadAttribute(AttributeNode node); std::optional loadRule(RuleNode node); std::optional loadCondition(ConditionNode node); std::optional loadPopup(PopupNode node, std::string name, Value::ValueType type); std::optional loadDisplay(DisplayNode node); std::optional loadWire(WireNode node); std::optional loadPin(PinNode pins); std::optional loadConnection(ConnectionNode node); std::optional loadBus(BusNode node); std::shared_ptr loadComponentInstance(InstanceNode instance, Library &library); std::shared_ptr loadBusInstance(InstanceNode instance, Library &library); /** Utility classes */ std::optional getBus(std::string name); std::optional getComponentPin(std::string name, std::string pin); bool hasAddressSpace(std::string name); std::optional createMemoryAttribute(); vector createWireEnumeration(vector enumeration); std::optional createMemoryPopup(); /** Context stack operations */ void push(ComdelContext context); void pushAdditional(std::string name); ComdelContext ¤t(); void pop(); }; } // namespace domain #endif // DOMAIN_COMDEL_GENERATOR_H