|
UniSet
2.2.1
|
00001 #ifndef Schema_H_ 00002 #define Schema_H_ 00003 // -------------------------------------------------------------------------- 00004 #include <memory> 00005 #include <unordered_map> 00006 #include "Element.h" 00007 #include "Schema.h" 00008 // -------------------------------------------------------------------------- 00009 class Schema 00010 { 00011 public: 00012 Schema(); 00013 virtual ~Schema(); 00014 00015 std::shared_ptr<Element> manage( std::shared_ptr<Element> el ); 00016 00017 void remove( std::shared_ptr<Element> el ); 00018 00019 void link( Element::ElementID rootID, Element::ElementID childID, int numIn ); 00020 void unlink( Element::ElementID rootID, Element::ElementID childID ); 00021 void extlink( const std::string& name, Element::ElementID childID, int numIn ); 00022 00023 void setIn( Element::ElementID ID, int inNum, bool state ); 00024 bool getOut( Element::ElementID ID ); 00025 00026 struct INLink; 00027 struct EXTLink; 00028 struct EXTOut; 00029 00030 typedef std::unordered_map<Element::ElementID, std::shared_ptr<Element>> ElementMap; 00031 typedef std::list<INLink> InternalList; 00032 typedef std::list<EXTLink> ExternalList; 00033 typedef std::list<EXTOut> OutputsList; 00034 00035 // map iterator 00036 typedef ElementMap::const_iterator iterator; 00037 inline Schema::iterator begin() 00038 { 00039 return emap.begin(); 00040 } 00041 inline Schema::iterator end() 00042 { 00043 return emap.end(); 00044 } 00045 inline int size() 00046 { 00047 return emap.size(); 00048 } 00049 inline bool empty() 00050 { 00051 return emap.empty(); 00052 } 00053 00054 // int. list iterator 00055 typedef InternalList::const_iterator INTiterator; 00056 inline Schema::INTiterator intBegin() 00057 { 00058 return inLinks.begin(); 00059 } 00060 inline Schema::INTiterator intEnd() 00061 { 00062 return inLinks.end(); 00063 } 00064 inline int intSize() 00065 { 00066 return inLinks.size(); 00067 } 00068 inline bool intEmpty() 00069 { 00070 return inLinks.empty(); 00071 } 00072 00073 // ext. list iterator 00074 typedef ExternalList::const_iterator EXTiterator; 00075 inline Schema::EXTiterator extBegin() 00076 { 00077 return extLinks.begin(); 00078 } 00079 inline Schema::EXTiterator extEnd() 00080 { 00081 return extLinks.end(); 00082 } 00083 inline int extSize() 00084 { 00085 return extLinks.size(); 00086 } 00087 inline bool extEmpty() 00088 { 00089 return extLinks.empty(); 00090 } 00091 00092 // ext. out iterator 00093 typedef OutputsList::const_iterator OUTiterator; 00094 inline Schema::OUTiterator outBegin() 00095 { 00096 return outList.begin(); 00097 } 00098 inline Schema::OUTiterator outEnd() 00099 { 00100 return outList.end(); 00101 } 00102 inline int outSize() 00103 { 00104 return outList.size(); 00105 } 00106 inline bool outEmpty() 00107 { 00108 return outList.empty(); 00109 } 00110 00111 // find 00112 std::shared_ptr<Element> find(Element::ElementID id); 00113 std::shared_ptr<Element> findExtLink(const std::string& name); 00114 std::shared_ptr<Element> findOut(const std::string& name); 00115 00116 // ----------------------------------------------- 00117 // внутренее соединения 00118 // между элементами 00119 struct INLink 00120 { 00121 INLink(std::shared_ptr<Element> f, std::shared_ptr<Element> t, int ni): 00122 numInput(ni) {} 00123 INLink(): numInput(0) {} 00124 00125 std::shared_ptr<Element> from; 00126 std::shared_ptr<Element> to; 00127 int numInput; 00128 }; 00129 00130 // внешнее соединение 00131 // что-то на вход элемента 00132 struct EXTLink 00133 { 00134 EXTLink( const std::string& n, std::shared_ptr<Element> t, int ni): 00135 name(n), to(t), numInput(ni) {} 00136 EXTLink(): name(""), numInput(0) {} 00137 00138 std::string name; 00139 std::shared_ptr<Element> to; 00140 int numInput; 00141 }; 00142 00143 // наружный выход 00144 struct EXTOut 00145 { 00146 EXTOut( const std::string& n, std::shared_ptr<Element>& f): 00147 name(n), from(f) {} 00148 EXTOut(): name("") {} 00149 00150 std::string name; 00151 std::shared_ptr<Element> from; 00152 }; 00153 00154 protected: 00155 ElementMap emap; // список элеметов 00156 InternalList inLinks; 00157 ExternalList extLinks; 00158 OutputsList outList; 00159 00160 private: 00161 }; 00162 // --------------------------------------------------------------------------- 00163 class SchemaXML: 00164 public Schema 00165 { 00166 public: 00167 SchemaXML(); 00168 virtual ~SchemaXML(); 00169 00170 void read( const std::string& xmlfile ); 00171 00172 protected: 00173 }; 00174 // --------------------------------------------------------------------------- 00175 #endif
1.7.6.1