00001
00002 #ifndef XMLUTIL_DICTNODE_H
00003 #define XMLUTIL_DICTNODE_H
00004
00005 #include <dom/DOM_Element.hpp>
00006 #include "xmlUtil/id/DictObject.h"
00007 #include "xmlUtil/id/DictField.h"
00008 #include "xmlUtil/id/DictConstraints.h"
00009 #include "xmlUtil/id/NamedId.h"
00010
00011 #include <vector>
00012 #include <algorithm>
00013 #include <iterator>
00014 #include <iostream>
00015
00016 namespace xmlUtil {
00018
00022 class DictFieldMan;
00023
00024 class DictNode : public DictObject {
00025 public:
00028 DictNode(DOM_Element elt, DictNode* parent, DictFieldMan *fieldMan);
00029
00030 ~DictNode();
00031 const DictField& getField() const {return *m_field;};
00032
00033
00034
00035
00036
00037 const DictConstraints& getValueConstraints() const {
00038 return *m_myConstraints;};
00039 const DictConstraints& getParentConstraints() const {
00040 return *m_parConstraints;};
00041 bool accept(DictVisitor* vis);
00042
00046 bool consistentChildren();
00047
00050 bool consistentParent();
00051
00054 bool consistentValues();
00055
00056
00057
00058
00059
00060
00061
00062 bool allowed(const unsigned value) const;
00065 bool allowedChild(std::string childField, unsigned childValue,
00066 unsigned myValue) const;
00069 bool allowedChild(unsigned childValue, unsigned myValue) const;
00070
00074 bool allowIdentifier(const Identifier& id, NamedId* named = 0);
00075
00078 bool allowNamedId(const NamedId& nId);
00079
00082 bool allowNameSeq(const NameSeq& seq) const;
00083
00085 class No_Assignment {};
00086
00087 private:
00088 friend class IdDict;
00089 friend class IdConverter;
00090 friend struct POrder;
00091
00092
00093
00094 typedef std::vector<DictNode*> Nodes;
00095 typedef std::vector<DictNode*>::iterator NodeIterator;
00096 typedef std::vector<DictNode*>::const_iterator ConstNodeIterator;
00097
00098
00099
00100 struct POrder {
00101 bool operator()(DictNode* a, DictNode* b) {
00102 return ((a->getParentConstraints()).getMin() <
00103 (b->getParentConstraints()).getMin() ); }
00104 };
00105
00106 const Nodes& getChildren() const {return m_children;}
00107
00109 static void setOstream(std::ostream* out) {m_err = out;}
00110
00111
00112
00113
00114
00115
00116
00117
00120
00124 bool allowedChild(const DictNode* const thisChild, unsigned childValue,
00125 unsigned myValue) const;
00126
00127
00129 bool allowIdentifier(Identifier::const_iterator idIt,
00130 Identifier::const_iterator end,
00131 NamedId* named=0);
00132
00134 bool allowNamedId(NamedId::FieldIt nIdIt,
00135 NamedId::FieldIt end);
00136
00137
00139 bool allowNameSeq(NameSeq::const_iterator seqIt,
00140 NameSeq::const_iterator end) const;
00141
00142 bool addChild(DictNode* child);
00143
00144
00147 bool valuesDisjoint(ConstNodeIterator start,
00148 ConstNodeIterator last);
00149
00150
00152 DictNode(const DictNode& toCopy);
00153
00154
00155 DictNode& operator=(const DictNode&);
00156 void deepCopy(const DictNode& toCopy);
00157
00159 DictNode() {};
00160
00161 Nodes m_children;
00162 const DictField* m_field;
00163 const DictNode* m_parent;
00164 DictConstraints* m_parConstraints;
00165 DictConstraints* m_myConstraints;
00166 static std::ostream* m_err;
00167
00168 };
00169 }
00170 #endif