- Main Page
- Related Pages
- Modules
- Classes
- Files

# PropertyValueConstraintList.h

Go to the documentation of this file.

    00001 #ifndef _PROPERTYVALUECONSTRAINTLIST_H_
    00002 #define _PROPERTYVALUECONSTRAINTLIST_H_
    00003
    00004 //
    00005 // Copyright (C) 2004-2006  Autodesk, Inc.
    00006 //
    00007 // This library is free software; you can redistribute it and/or
    00008 // modify it under the terms of version 2.1 of the GNU Lesser
    00009 // General Public License as published by the Free Software Foundation.
    00010 //
    00011 // This library is distributed in the hope that it will be useful,
    00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00014 // Lesser General Public License for more details.
    00015 //
    00016 // You should have received a copy of the GNU Lesser General Public
    00017 // License along with this library; if not, write to the Free Software
    00018 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    00019 //
    00020
    00021 #ifdef _WIN32
    00022 #pragma once
    00023 #endif
    00024
    00025 #include <FdoStd.h>
    00026 #include <Fdo/Schema/PropertyValueConstraint.h>
    00027 #include <Fdo/Expression/DataValueCollection.h>
    00028
    00029 /// \brief
    00030 /// FdoPropertyValueConstraintList is used to specify a list of allowed values for a particular property.
    00031 /// It can be used for all data property types except for Boolean, BLOB, or CLOB.
    00032 /// This constraint is represented by a list of values of the same type as the corresponding data property.
    00033 /// The list cannot be empty. The list could be a single value. While that may not seem very useful it could serve as a
    00034 /// temporary way to enforce a single value for a property, e.g. for a particular customer, Parcel.State is always 'CA'
    00035 /// In this case, the definer of the property definition probably should also set the default value to be the same, unless it can be null.
    00036 /// The list does not need to be ordered. However, a provider may choose to reorder the list so the list that is returned when
    00037 /// a user gets the definition of this constraint for a property may be different than the order that was given when defined.
    00038 /// E.g. defined as (12, 8, 24), but returned as (8, 12, 24). If the list has duplicate values, the provider may choose to eliminate
    00039 /// duplicates from the list.
    00040 /// If the data property definition allows nulls, a null value is considered as being valid regardless of this list of valid values.
    00041 /// The list of valid values should not include the null value itself, but leave the specification of whether null is allowed to
    00042 /// the null value constraint. If the data property definition includes a non-null default value, then that value should be one
    00043 /// of the values in the list.
    00044 /// If both a valid values list constraint and a unique constraint on the same property are included, then the side effect is that
    00045 /// there will be an upper limit of the number of objects of that class that have non-null values for the property.
    00046 class FdoPropertyValueConstraintList : public FdoPropertyValueConstraint
    00047 {
    00048 protected:
    00049     /// Constructs a default instance of a FdoPropertyValueConstraintList.
    00050     FdoPropertyValueConstraintList();
    00051
    00052     virtual ~FdoPropertyValueConstraintList();
    00053
    00054     virtual void Dispose()
    00055     {
    00056         delete this;
    00057     }
    00058 public:
    00059
    00060     /// \brief
    00061     /// Constructs an empty instance of an FdoPropertyValueConstraintList.
    00062     ///
    00063     /// \return
    00064     /// Returns an FdoPropertyValueConstraintList
    00065     ///
    00066     FDO_API static FdoPropertyValueConstraintList* Create( );
    00067
    00068     /// \brief
    00069     /// Returns the list of allowed values for a particular property.
    00070     ///
    00071     /// \return
    00072     /// Returns na instance of FdoDataValueCollection.
    00073     ///
    00074     FDO_API FdoDataValueCollection* GetConstraintList();
    00075
    00076     /// \brief
    00077     /// Returns FdoPropertyValueConstraintType_Range type.
    00078     ///
    00079     /// \return
    00080     /// Returns the constraint type
    00081     ///
    00082     FDO_API virtual FdoPropertyValueConstraintType GetConstraintType();
    00083
    00084 /// \cond DOXYGEN-IGNORE
    00085     // Public non-API functions for XML and Schema Merge support
    00086
    00087     /// Update this list constraint from the given value constraint.
    00088     virtual void Set( FdoPropertyValueConstraint* pProperty, FdoString* parentName, FdoSchemaMergeContext* pContext );
    00089
    00090     // \brief
    00091     // Compares this list constraint with another one.
    00092     //
    00093     // \param value
    00094     // The Property Value constraint to compare with
    00095     //
    00096     // \return
    00097     // Returns true if this list constraint is the same as pConstraint
    00098     // (same constraint type and all members have the same values).
    00099     virtual bool Equals( FdoPropertyValueConstraint* pConstraint );
    00100
    00101     // \brief
    00102     // Checks if a constraint domain is contained within another
    00103     //
    00104     // \param value
    00105     // The Property Value constraint to compare with
    00106     //
    00107     // \return
    00108     // Returns true if this constraint's domain is a superset of the domain
    00109     // for pConstraint (all values that do not violate pConstraint also do not
    00110     // violate this constraint).
    00111     virtual bool Contains( FdoPropertyValueConstraint* pConstraint );
    00112
    00113     // \brief
    00114     // Checks if the given value violates this constraint.
    00115     //
    00116     // \param value
    00117     // The Property Value
    00118     //
    00119     // \return
    00120     // Returns true if the value is null or is in this constraint's value list.
    00121     // Returns false if the value does violate this constraint.
    00122     virtual bool Contains( FdoDataValue* pValue );
    00123
    00124 private:
    00125     // Builds dictionary from given data values, filtering out duplicates.
    00126     FdoDictionaryP ValuesToDictionary( FdoDataValueCollection* values );
    00127
    00128     FdoDataValueCollection* m_constraintList;
    00129 /// \endcond
    00130 };
    00131 #endif
    00132
    00133

Please send us your comment about this page