Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

/home/pauldt/projects/IDEA/IDEA-ALL/IDEA-DEV/Core/PlanServer/Includes/PslVariable.hh

Go to the documentation of this file.
00001 // -*- Mode: c++ -*-
00002 //     File: $Source: /home/cvs/ISG-Repository/IDEA-DEV/Core/PlanServer/Includes/PslVariable.hh,v $
00003 //      Tag: $Name: DR_01_11_06 $
00004 //      CVS: $Id: PslVariable.hh,v 1.16 2005/06/20 21:22:06 olvov Exp $
00005 //     Info: $CVSROOT/Idea3/Copyright.txt
00006 #ifndef PSL_VARIABLE_HEADER_
00007 #define PSL_VARIABLE_HEADER_
00008 
00009 #include "Utilities.hh"
00010 
00011 #include "PslDataTypes.hh"
00012 #include "PslVariableImpl.hh"
00013 
00014 #include <set>
00015 #include <algorithm>
00016 
00017 namespace IDEA
00018 {
00019   template <class Type>
00020   bool isTypeNumeric();
00021 
00022   class PslConstraint;
00023   class PslDatabase;
00024   class PslDomain;
00025   class PslObject;
00026   class PslObjectClass;
00027   class PslLabel;
00028   class PslLabelSet;
00029 
00042   class PslVariable
00043   {
00044     friend class PslDatabaseImpl;
00045   public:
00049     ~PslVariable();
00050 
00051     PslVariableImpl* getImpl() const;
00052 
00053     const PslDatabase* getDatabase() const;
00057     int getId() const;
00061     bool write( std::string& value ) const;
00065     bool read( const std::string& value ) const;
00074     void commit() const;
00078     const std::string getName() const;
00082     void print(std::ostream &) const;
00088     const PslDataType getDataType() const;
00092     bool isInterval() const;
00098     bool isEmpty() const;
00104     bool isDynamic() const;
00109     bool isSingleton() const;
00114     bool isEnumerated() const;
00119     bool isFinite() const;
00123     const PslConstraintList getConstraints() const;
00129     void removeConstraint( const PslConstraint* cnstr ) const;
00133     int getSize() const;
00137     template <class Type>
00138     Type getSingleton() const
00139     {
00140       PSL_ASSERT( m_Impl != 0, PslNoImpl );
00141       PSL_ASSERT( isSingleton(), PslSingletonNotSet );
00142 
00143       return m_Impl->getSingleton<Type>();
00144     }
00151     template <class Type>
00152     Type getMinimum() const
00153     {
00154       PSL_ASSERT( m_Impl != 0, PslNoImpl );
00155 
00156       return m_Impl->getMinimum<Type>();
00157     }
00164     template <class Type>
00165     Type getMaximum() const
00166     {
00167       PSL_ASSERT( m_Impl != 0, PslNoImpl );
00168 
00169       return m_Impl->getMaximum<Type>();
00170     }
00171 
00172     template <class Type>
00173     void setMinimum( Type v ) const
00174     {
00175       PSL_ASSERT( m_Impl != 0, PslNoImpl );
00176 
00177       return m_Impl->setMinimum<Type>( v );
00178     }
00179 
00180     template <class Type>
00181     void setMaximum( Type v ) const
00182     {
00183       PSL_ASSERT( m_Impl != 0, PslNoImpl );
00184 
00185       return m_Impl->setMaximum<Type>( v );
00186     }
00187 
00191     template <class Type>
00192     std::set<Type> getMembers() const
00193     {
00194       PSL_ASSERT( m_Impl != 0, PslNoImpl );
00195 
00196       return m_Impl->getMembers<Type>();
00197     }
00202     template <class Type>
00203     bool hasMember(const Type val) const
00204     {
00205       PSL_ASSERT( m_Impl != 0, PslNoImpl );
00206 
00207       return m_Impl->hasMember<Type>(val);
00208     }
00212     bool hasIntersection( const PslVariable* variable ) const;
00216     void intersect( const PslVariable* other) const;
00220     template <class Type>
00221     void setToSingleton(Type newVal) const
00222     {
00223       PSL_ASSERT( m_Impl != 0, PslNoImpl );
00224       
00225       m_Impl->setToSingleton(newVal);
00226     }
00230     template <class Type>
00231     void setToInterval(Type min, Type max) const
00232     {
00233       PSL_ASSERT( m_Impl != 0, PslNoImpl );
00234 
00235       m_Impl->setToInterval<Type>(min, max);
00236     }
00241     template <class Type>
00242     void setMembers( const std::set<Type>& newSet ) const
00243     {
00244       PSL_ASSERT( m_Impl != 0, PslNoImpl );
00245 
00246       m_Impl->setMembers<Type>(newSet);
00247     }
00251    template <class Type>
00252    void remove(Type val) const
00253     {
00254       PSL_ASSERT( m_Impl != 0, PslNoImpl );
00255 
00256       return m_Impl->remove<Type>(val);
00257     }
00258    template <class Type>
00259    const PslConstraint* constrainTo( Type val, int authority ) const
00260     {
00261       PSL_ASSERT( m_Impl != 0, PslNoImpl );
00262 
00263       return m_Impl->constrainTo<Type>(val, authority );
00264     }
00265 
00266    template <class Type>
00267    const PslConstraint* constrainToInterval( Type min, Type max, int authority ) const
00268     {
00269       PSL_ASSERT( m_Impl != 0, PslNoImpl );
00270 
00271       return m_Impl->constrainToInterval<Type>( min, max, authority );
00272     }
00276     template <class Type>
00277     void insert( Type newVal ) const
00278     {
00279       PSL_ASSERT( m_Impl != 0, PslNoImpl );
00280       PSL_ASSERT( m_Impl->isDynamic(), PslConvention );
00281 
00282       m_Impl->insert<Type>(newVal);
00283     }
00291     void reset() const;
00292 
00298     bool conditionallyReset( const IntSet& authorities ) const;
00302     void setStatic() const;
00303   protected:
00309     PslVariableImpl* m_Impl;
00310   private:
00314     PslVariable( PslVariableImpl* impl );
00318     PslVariable( const PslDatabase* database, const PslDomain* domain, const std::string& name );
00322     PslVariable();
00323   };
00324 
00328   std::ostream & operator<<(std::ostream & os, const PslVariable& variable);
00329 }
00330 
00331 #endif // PSL_VARIABLE_HEADER_

Contact information
© IDEA
Generated on Fri Feb 3 17:09:41 2006 for IDEA.