sdRelationship.h

Go to the documentation of this file.
00001 // *****************************************************************************
00002 // *****************************************************************************
00003 // sdRelationship.h
00004 //
00005 // This file contains the definitions for the following classes.
00006 //
00007 //  sdRelationshipOrderingType
00008 //      This class is a wrapper around sdRelationshipOrderingTypeEnum. The enum
00009 //      values specify whether a relationship is strictly ordered, unordered or
00010 //      optionally ordered.
00011 //
00012 //  sdRelationshipAssociationType
00013 //      This class is a wrapper around sdRelationshipAssociationTypeEnum. The
00014 //      enum values specify whether a relationship is an peer, owned or owner
00015 //      relationship.
00016 //
00017 //  sdRelationshipActionType
00018 //      This class is a wrapper around sdRelationshipActionTypeEnum. The
00019 //      sdRelationshipActionTypeEnum enum defines the various actions that can
00020 //      be performed on a relationship.
00021 //
00022 //  sdRelationshipMultiplicityType 
00023 //      This is a wrapper around sdRelationshipMultiplicityTypeEnum. The enum
00024 //      values specify the multiplicity of the relationship, whether it is one 
00025 //      to one or one to many relationship etc.
00026 // 
00027 //  sdRelationshipSubType 
00028 //      This is a wrapper around sdRelationshipSubTypeEnum. A relationship can
00029 //      be between 2 classes or it can be from 1 class to a set of classes
00030 //      sdRelationshipSubTypeEnum captures the different types of relationships.
00031 //
00032 //  sdRelationshipContainerType
00033 //      This class is a wrapper around the sdRelationshipContainerTypeEnum
00034 //      values. The enum values of sdRelationshipContainerTypeEnum define
00035 //      different ways the related object can be returned.
00036 //
00037 //  sdRelationshipBase
00038 //      This class is a the base class for representing of different types of
00039 //      relationships.
00040 //
00041 //  sdRelationship
00042 //      This is the schema class for representing a relationship between 2 
00043 //      classes.
00044 //
00045 //  sdRelationshipSet
00046 //      This is the schema class for representing a relationship that involves 
00047 //      a single 'from' class and multiple 'to' classes. The 'to' set of
00048 //      classes is a list of valid classes that can have this relationship.
00049 // 
00050 // *****************************************************************************
00051 // Except as specified in the OpenAccess terms of use of Cadence or Silicon
00052 // Integration Initiative, this material may not be copied, modified,
00053 // re-published, uploaded, executed, or distributed in any way, in any medium,
00054 // in whole or in part, without prior written permission from Cadence.
00055 //
00056 //                Copyright 2007 Cadence Design Systems, Inc.
00057 //                           All Rights Reserved.
00058 //
00059 //  $Author: icftcm $
00060 //  $Revision: #1 $
00061 //  $Date: 2007/03/20 $
00062 //  $State: Exp $
00063 // *****************************************************************************
00064 // *****************************************************************************
00065 
00066 
00067 
00068 #if !defined(sdRelationship_P)
00069 #define sdRelationship_P
00070 
00071 
00072 
00073 // *****************************************************************************
00074 // Nested includes
00075 // *****************************************************************************
00076 #include <vector>
00077 #include "sdBase.h"
00078 
00079 
00080 
00081 // *****************************************************************************
00082 // Declare and define types in the schema definition namespace.
00083 // *****************************************************************************
00084 BEGIN_SD_NAMESPACE
00085 
00086 
00087 
00088 // *****************************************************************************
00089 // Forward Public Class Declarations
00090 // *****************************************************************************
00091 class sdObject;
00092 
00093 
00094 
00095 // *****************************************************************************
00096 // sdRelationshipOrderingTypeEnum
00097 // *****************************************************************************
00098 #define sdvNumRelationshipOrderingTypes 3
00099 
00100 enum sdRelationshipOrderingTypeEnum {
00101     sdcUnorderedRelationshipOrderingType            = 0,
00102     sdcStrictlyOrderedRelationshipOrderingType      = 1,
00103     sdcOptionallyOrderedRelationshipOrderingType    = 2
00104 };
00105 
00106 
00107 
00108 // *****************************************************************************
00109 // sdRelationshipAssociationTypeEnum
00110 // *****************************************************************************
00111 #define sdvNumRelationshipAssociationTypes 3
00112 
00113 enum sdRelationshipAssociationTypeEnum {
00114     sdcOwnedRelationshipAssociationType = 0,
00115     sdcOwnerRelationshipAssociationType = 1,
00116     sdcPeerRelationshipAssociationType  = 2
00117 };
00118 
00119 
00120 
00121 // *****************************************************************************
00122 // sdRelationshipMultiplicityTypeEnum
00123 // *****************************************************************************
00124 #define sdvNumRelationshipMultiplicityTypes 4
00125 
00126 enum sdRelationshipMultiplicityTypeEnum {
00127     sdcOneToOneRelationshipMultiplicityType         = 0,
00128     sdcOneToZeroOrOneRelationshipMultiplicityType   = 1,
00129     sdcOneToOneOrManyRelationshipMultiplicityType   = 2,
00130     sdcOneToZeroOrManyRelationshipMultiplicityType  = 3
00131 };
00132 
00133 
00134 
00135 // *****************************************************************************
00136 // sdRelationshipActionTypeEnum
00137 // *****************************************************************************
00138 #define sdvNumRelationshipActionTypes 4
00139 
00140 enum sdRelationshipActionTypeEnum {
00141     sdcGetRelationshipActionType        = 1,
00142     sdcCreateRelationshipActionType     = 2,
00143     sdcDestroyRelationshipActionType    = 4,
00144     sdcInitRelationshipActionType       = 8
00145 };
00146 
00147 
00148 
00149 // *****************************************************************************
00150 // sdRelationshipSubTypeEnum
00151 // *****************************************************************************
00152 #define sdvNumRelationshipSubTypes 2
00153 
00154 enum sdRelationshipSubTypeEnum {
00155     sdcSingleRelationshipSubType    = 0,
00156     sdcSetRelationshipSubType       = 1
00157 };
00158 
00159 
00160 
00161 // *****************************************************************************
00162 // sdRelationshipContainerTypeEnum
00163 // *****************************************************************************
00164 #define sdvNumRelationshipContainerTypes 4
00165 
00166 enum sdRelationshipContainerTypeEnum {
00167     sdcSingleRelationshipContainerType      = 0,
00168     sdcArrayRelationshipContainerType       = 1,
00169     sdcCollectionRelationshipContainerType  = 2,
00170     sdc2DTableRelationshipContainerType     = 3
00171 };
00172 
00173 
00174 
00175 // *****************************************************************************
00176 // sdRelationshipOrderingType
00177 // *****************************************************************************
00178 class SD_DLL_API sdRelationshipOrderingType {
00179 public:         
00180                                     sdRelationshipOrderingType(sdRelationshipOrderingTypeEnum valueType);
00181                                     sdRelationshipOrderingType(const std::string &name);
00182                                     ~sdRelationshipOrderingType();
00183 
00184                                     operator                sdRelationshipOrderingTypeEnum() const;
00185     const std::string               &getName() const;
00186 
00187 private:
00188     static const std::string        *initNames();
00189 
00190     sdRelationshipOrderingTypeEnum  m_value;
00191 
00192     static const std::string        *s_names;
00193 };
00194 
00195 
00196 
00197 // *****************************************************************************
00198 // sdRelationshipAssociationType
00199 // *****************************************************************************
00200 class SD_DLL_API sdRelationshipAssociationType {
00201 public:         
00202                                         sdRelationshipAssociationType(sdRelationshipAssociationTypeEnum valueType);
00203                                         sdRelationshipAssociationType(const std::string &name);
00204                                         ~sdRelationshipAssociationType();
00205 
00206                                         operator                    sdRelationshipAssociationTypeEnum() const;
00207     const std::string                   &getName() const;
00208 
00209 private:
00210     static const std::string            *initNames();
00211 
00212     sdRelationshipAssociationTypeEnum   m_value;
00213 
00214     static const std::string            *s_names;
00215 };
00216 
00217 
00218 
00219 // *****************************************************************************
00220 // sdRelationshipActionType
00221 // *****************************************************************************
00222 class SD_DLL_API sdRelationshipActionType {
00223 public:
00224                                     sdRelationshipActionType(sdRelationshipActionTypeEnum valueType);
00225                                     sdRelationshipActionType(const std::string &name);
00226                                     ~sdRelationshipActionType();
00227 
00228                                     operator                sdRelationshipActionTypeEnum() const;
00229     const std::string               &getName() const;
00230 
00231 private:
00232     static const std::string        *initNames();
00233 
00234     sdRelationshipActionTypeEnum    m_value;
00235 
00236     static const std::string        *s_names;
00237 };
00238 
00239 
00240 
00241 // *****************************************************************************
00242 // sdRelationshipMultiplicityType
00243 // *****************************************************************************
00244 class SD_DLL_API sdRelationshipMultiplicityType {
00245 public:         
00246                                         sdRelationshipMultiplicityType(sdRelationshipMultiplicityTypeEnum valueType);
00247                                         sdRelationshipMultiplicityType(const std::string &name);
00248                                         ~sdRelationshipMultiplicityType();
00249 
00250                                         operator                    sdRelationshipMultiplicityTypeEnum() const;
00251     const std::string                   &getName() const;
00252 
00253 private:
00254     static const std::string            *initNames();
00255 
00256     sdRelationshipMultiplicityTypeEnum  m_value;
00257 
00258     static const std::string            *s_names;
00259 };
00260 
00261 
00262 
00263 // *****************************************************************************
00264 // sdRelationshipSubType
00265 // *****************************************************************************
00266 class SD_DLL_API sdRelationshipSubType {
00267 public:         
00268                                 sdRelationshipSubType(sdRelationshipSubTypeEnum valueType);
00269                                 sdRelationshipSubType(const std::string &name);
00270                                 ~sdRelationshipSubType();
00271 
00272                                 operator                    sdRelationshipSubTypeEnum() const;
00273     const std::string           &getName() const;
00274 
00275 private:
00276     static const std::string    *initNames();
00277 
00278     sdRelationshipSubTypeEnum   m_value;
00279 
00280     static const std::string    *s_names;
00281 };
00282 
00283 
00284 
00285 // *****************************************************************************
00286 // sdRelationshipContainerType
00287 // *****************************************************************************
00288 class SD_DLL_API sdRelationshipContainerType {
00289 public:         
00290                                     sdRelationshipContainerType(sdRelationshipContainerTypeEnum container);
00291                                     sdRelationshipContainerType(const std::string &name);
00292                                     ~sdRelationshipContainerType();
00293 
00294                                     operator                sdRelationshipContainerTypeEnum() const;
00295     const std::string               &getName() const;
00296 
00297 private:
00298     static const std::string        *initNames();
00299 
00300     sdRelationshipContainerTypeEnum m_value;
00301 
00302     static const std::string        *s_names;
00303 };
00304 
00305 
00306 
00307 // *****************************************************************************
00308 // sdRelationshipBase
00309 // *****************************************************************************
00310 class SD_DLL_API sdRelationshipBase : public sdBase {
00311 public:         
00312     typedef std::vector<sdRelationshipActionType>   Actions;
00313     typedef Actions::const_iterator                 ActionConstIter;
00314 
00315     virtual                                         ~sdRelationshipBase();
00316 
00317     unsigned int                                    getId() const;
00318     const std::string                               &getName() const;
00319     const std::string                               &getDescription() const;
00320     sdRelationshipSubType                           getSubType() const;
00321 
00322     sdRelationshipOrderingType                      getOrderType() const;
00323     sdRelationshipAssociationType                   getAssociationType() const;
00324     sdRelationshipMultiplicityType                  getMultiplicityType() const;
00325     sdRelationshipContainerType                     getContainerType() const;
00326 
00327     ActionConstIter                                 begin() const;
00328     ActionConstIter                                 end() const;
00329 
00330 protected:
00331                                                     sdRelationshipBase(unsigned int                     id,
00332                                                                        const std::string                &name,
00333                                                                        const std::string                &relDescription,
00334                                                                        sdRelationshipOrderingType       orderType,
00335                                                                        const Actions                    &actions,
00336                                                                        sdRelationshipAssociationType    associationType,
00337                                                                        sdRelationshipMultiplicityType   multiplicityType,
00338                                                                        sdRelationshipContainerType      containerType,
00339                                                                        sdRelationshipSubType            subType,
00340                                                                        sdNameSpace                      *nameSpace);
00341 
00342 private:
00343     const unsigned int                              m_id;
00344     const std::string                               &m_name;
00345     const std::string                               m_description;
00346     const Actions                                   m_actions;
00347 
00348     const sdRelationshipAssociationType             m_associationType;
00349     const sdRelationshipMultiplicityType            m_multiplicityType;
00350 
00351     const sdRelationshipOrderingType                m_orderType;
00352     const sdRelationshipContainerType               m_containerType;
00353     const sdRelationshipSubType                     m_subType;
00354 };
00355 
00356 
00357 
00358 // *****************************************************************************
00359 // sdRelationship
00360 // *****************************************************************************
00361 class SD_DLL_API sdRelationship : public sdRelationshipBase {
00362 public:
00363                             sdRelationship(unsigned int                     id,
00364                                            const std::string                &name,
00365                                            const std::string                &relDescription,
00366                                            sdRelationshipOrderingType       orderType,
00367                                            const Actions                    &actions,
00368                                            sdRelationshipAssociationType    associationType,
00369                                            sdRelationshipMultiplicityType   multiplicityType,
00370                                            sdRelationshipContainerType      containerType,
00371                                            sdNameSpace                      *nameSpace,
00372                                            const sdObject                   *from,
00373                                            const sdObject                   *to);
00374     virtual                 ~sdRelationship();
00375 
00376     const sdObject          *getFrom() const;
00377     const sdObject          *getTo() const;
00378 
00379     virtual void            accept(sdVisitor *visitor);
00380 
00381 private:
00382     const sdObject          *m_from;
00383     const sdObject          *m_to;
00384 };
00385 
00386 
00387 
00388 // *****************************************************************************
00389 // sdRelationshipSet
00390 // *****************************************************************************
00391 class SD_DLL_API sdRelationshipSet : public sdRelationshipBase {
00392 public:
00393     typedef std::vector<const sdObject*>    ObjectVector;
00394     typedef ObjectVector::const_iterator    ObjectConstIter;
00395 
00396                                             sdRelationshipSet(unsigned int                      id,
00397                                                               const std::string                 &name,
00398                                                               const std::string                 &relDescription,
00399                                                               sdRelationshipOrderingType        orderType,
00400                                                               const Actions                     &actions,
00401                                                               sdRelationshipAssociationType     associationType,
00402                                                               sdRelationshipMultiplicityType    multiplicityType,
00403                                                               sdRelationshipContainerType       containerType,
00404                                                               sdNameSpace                       *nameSpace,
00405                                                               const sdObject                    *from,
00406                                                               const ObjectVector                &toObjects);
00407     virtual                                 ~sdRelationshipSet();
00408 
00409     const sdObject                          *getFrom() const;
00410     ObjectConstIter                         beginToObject() const;
00411     ObjectConstIter                         endToObject()  const;
00412 
00413     virtual void                            accept(sdVisitor *visitor);
00414 
00415 private:
00416     const sdObject                          *m_from;
00417     const ObjectVector                      m_to;
00418 };
00419 
00420 
00421 
00422 END_SD_NAMESPACE
00423 
00424 #endif

Return to top of page