00001 // $Header: /nfs/slac/g/glast/ground/cvs/xmlUtil/xmlUtil/id/DictConstraints.h,v 1.6 2002/04/05 18:28:44 jrb Exp $ 00002 00003 #ifndef XMLUTIL_DICTCONSTRAINTS_H 00004 #define XMLUTIL_DICTCONSTRAINTS_H 00005 00006 #include <vector> 00007 #include <dom/DOM_Element.hpp> 00008 #include "xmlUtil/id/DictVisitor.h" 00009 #include <set> 00010 00011 namespace xmlUtil { 00013 00014 00015 class DictConstraints { 00016 public: 00017 00019 DictConstraints(DOM_Element elt); 00020 bool equals(const DictConstraints& other); 00021 ~DictConstraints(){if (m_valList) delete m_valList;} 00022 public: 00024 bool allowed(const unsigned value) const; 00025 00028 bool allowed(const DictConstraints& other) const; 00029 bool allowed(DictConstraints *other) const; 00030 bool disjoint(const DictConstraints& other) const; 00031 bool disjoint(DictConstraints* other) const; 00032 00033 unsigned getMin() const {return m_minVal;} 00034 unsigned getMax() const {return m_maxVal;} 00035 // bool isList() const {return (m_valList != 0);} 00036 00039 void insertValues(std::set<unsigned>& aSet) const; 00040 00041 // DictNode needs to make copies of DictConstraints objects in 00042 // some of its private constructors 00043 DictConstraints(const DictConstraints& toCopy); 00044 DictConstraints& operator=(const DictConstraints&); 00045 00046 private: 00047 typedef std::vector<unsigned> DictValList; 00048 00050 void deepCopy(const DictConstraints& toCopy); 00051 00052 enum eStyle { 00053 ESTYLE_uninit = 0, 00054 ESTYLE_single = 1, 00055 ESTYLE_interval = 2, 00056 ESTYLE_list = 3 00057 }; 00058 eStyle m_style; 00059 00060 DictValList *m_valList; 00061 unsigned m_minVal; 00062 unsigned m_maxVal; 00063 00065 DictConstraints() : m_style(ESTYLE_uninit), m_valList(0) {}; 00066 00067 eStyle getType() const {return m_style;} 00068 00069 DictConstraints(const unsigned soleValue); 00070 DictConstraints(const unsigned min, const unsigned max); 00071 DictConstraints(const DictValList * const list); 00072 00073 }; // end DictConstraints class 00074 } // end xmlUtil namespace 00075 00076 #endif
1.2.13.1 written by Dimitri van Heesch,
© 1997-2001