ValueCheck.hpp

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------\
00002 |                                                                      |
00003 |                     _     _   _   _     __     _                     |
00004 |                    | |   | | | \_/ |   /  \   | |                    |
00005 |                    | |   | | | |_| |  / /\ \  | |                    |
00006 |                    | |__ | | | | | | / ____ \ | |__                  |
00007 |                    |____||_| |_| |_|/ /    \ \|____|                 |
00008 |                                                                      |
00009 |                             core library                             |
00010 |                                                                      |
00011 |                                         (C) SUSE Linux Products GmbH |
00012 \----------------------------------------------------------------------/
00013 
00014   File:       ValueCheck.hpp
00015 
00016   Author:     Marius Tomaschewski
00017   Maintainer: Marius Tomaschewski
00018 
00019   Purpose:
00020 
00021 /-*/
00026 #ifndef    LIMAL_VALUE_CHECK_HPP
00027 #define    LIMAL_VALUE_CHECK_HPP
00028 
00029 #include  <limal/config.h>
00030 #include  <blocxx/String.hpp>
00031 #include  <blocxx/RefCount.hpp>
00032 #include  <blocxx/List.hpp>
00033 
00034 namespace LIMAL_NAMESPACE
00035 {
00036 
00040 class ValueCheck;
00041 
00042 // -------------------------------------------------------------------
00054 class ValueCheckBase
00055 {
00056 public:
00060         virtual
00061         ~ValueCheckBase()
00062         {
00063         }
00064 
00083         virtual bool
00084         isValid(const blocxx::String &value) const = 0;
00085 
00102         virtual blocxx::String
00103         explain(const blocxx::String &value) const = 0;
00104 
00105 protected:
00109         ValueCheckBase()
00110                 : m_rcnt(0)
00111         {
00112         }
00113 
00114 private:
00120         ValueCheckBase(const ValueCheckBase &);
00121 
00125         ValueCheckBase & operator = (const ValueCheckBase &);
00126 
00131         friend class ValueCheck;
00132 
00136         blocxx::RefCount m_rcnt;
00137 };
00138 
00139 
00140 // -------------------------------------------------------------------
00191 class ValueCheck: public ValueCheckBase
00192 {
00193 public:
00200         ValueCheck();
00201 
00206         ValueCheck(ValueCheckBase *check);
00207 
00213         ValueCheck & operator=(ValueCheckBase *check);
00214 
00219         ValueCheck(const ValueCheck &ref);
00220 
00226         ValueCheck & operator=(const ValueCheck &ref);
00227 
00231         virtual ~ValueCheck();
00232 
00241         virtual bool
00242         isValid(const blocxx::String &value) const;
00243 
00251         virtual blocxx::String
00252         explain(const blocxx::String &value) const;
00253 
00261         ValueCheck&
00262         And(const ValueCheck &ref);
00263 
00271         ValueCheck&
00272         And(ValueCheckBase *check);
00273 
00281         ValueCheck&
00282         Or(const ValueCheck &ref);
00283 
00291         ValueCheck&
00292         Or(ValueCheckBase *check);
00293 
00310         ValueCheck&
00311         Not();
00312 
00313 private:
00314         /*
00315         ** Relationship operators
00316         */
00317         enum ECheckOp { E_AND, E_OR };
00318 
00327         ValueCheck(const ValueCheck &ref, ECheckOp op);
00328 
00333         void
00334         incRCnt(ValueCheckBase *ptr);
00335 
00341         void
00342         delRCnt(ValueCheckBase *ptr);
00343 
00347         ECheckOp                        m_cop;
00348 
00352         bool                            m_neg;
00353 
00357         ValueCheckBase *                m_self;
00358 
00362         blocxx::List<ValueCheck>        m_list;
00363 };
00364 
00365 
00366 }       // End of LIMAL_NAMESPACE
00367 #endif  // LIMAL_VALUE_CHECK_HPP
00368 // vim: set ts=8 sts=8 sw=8 ai noet:

Generated on Mon Nov 27 22:20:57 2006 for limal by  doxygen 1.5.0