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