00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef _GEDDEI_NETWORKSPEC_H
00012 #define _GEDDEI_NETWORKSPEC_H
00013
00014 #include <qstringlist.h>
00015 #include <qmap.h>
00016 #include <qvaluelist.h>
00017 #include <qdom.h>
00018 #include <qstring.h>
00019
00020 #ifdef __GEDDEI_BUILD
00021 #include "properties.h"
00022 #else
00023 #include <geddei/properties.h>
00024 #endif
00025
00026 class LinkSpec
00027 {
00028 QString theSinkName;
00029 uint theSinkIndex;
00030 public:
00031 friend ostream &operator<<(ostream &out, LinkSpec &me)
00032 {
00033 return out << me.theSinkName << "/" << me.theSinkIndex;
00034 }
00035
00036 LinkSpec(const QString &sinkName = "", uint sinkIndex = 0): theSinkName(sinkName), theSinkIndex(sinkIndex) {}
00037 LinkSpec(QDomElement &e);
00038 };
00039
00040 class PortSpec
00041 {
00042 QValueList<LinkSpec> theLinks;
00043 public:
00044 friend ostream &operator<<(ostream &out, PortSpec &me)
00045 {
00046 if(me.theLinks.isEmpty()) return out << "-";
00047 if(me.theLinks.count() == 1) return out << me.theLinks.front();
00048 out << "{";
00049 for(QValueList<LinkSpec>::iterator i = me.theLinks.begin(); i != me.theLinks.end(); i++)
00050 out << (i==me.theLinks.begin()?"":",") << *i;
00051 return out << "}";
00052 }
00053
00054 PortSpec() {}
00055 PortSpec(QDomElement &e);
00056 };
00057
00058 class ProcessorSpec
00059 {
00060 public:
00061 enum Family
00062 {
00063 None = 0,
00064 MainSource,
00065 MainSink,
00066 Factory,
00067 SubFactory
00068 };
00069
00070 private:
00071 QString theName, theType;
00072 Family theFamily;
00073 QMap<uint, PortSpec> theOutputs;
00074
00075 public:
00076 const QString &name() const { return theName; }
00077 const QString &type() const { return theType; }
00078 const Family family() const { return theFamily; }
00079 const Geddei::Properties properties() const { return Geddei::Properties(); }
00080
00081 friend ostream &operator<<(ostream &out, ProcessorSpec &me)
00082 {
00083 if(me.theFamily == Factory)
00084 out << "[ P:" << me.theName << " | ";
00085 else if(me.theFamily == SubFactory)
00086 out << "[ S:" << me.theName << " | ";
00087 else if(me.theFamily == MainSource)
00088 out << "[ > | ";
00089 else if(me.theFamily == MainSink)
00090 out << "[ < ";
00091 for(uint i = 0; i < me.theOutputs.size(); i++)
00092 out << me.theOutputs[i] << " ";
00093 return out << "]";
00094 }
00095
00096 ProcessorSpec(QDomElement &e);
00097 ProcessorSpec() { theFamily = None; }
00098 };
00099
00100 class NetworkSpec
00101 {
00102 QMap<QString, ProcessorSpec> theProcessors;
00103 uint theRealCount;
00104
00105 public:
00106 void load(const QString &filename);
00107 const uint realCount() { return theRealCount; }
00108
00109 const QStringList names() const { return theProcessors.keys(); }
00110 const ProcessorSpec &operator[](const QString name) const { return theProcessors[name]; }
00111
00112 friend ostream &operator<<(ostream &out, NetworkSpec &me)
00113 {
00114 for(QMap<QString, ProcessorSpec>::iterator i = me.theProcessors.begin(); i != me.theProcessors.end(); i++)
00115 out << *i << endl;
00116 return out;
00117 }
00118
00119 NetworkSpec(const QString &filename) { load(filename); }
00120 };
00121
00122 class FileOpenException {};
00123
00124 #endif