sdObject.h

Go to the documentation of this file.
00001 // *****************************************************************************
00002 // *****************************************************************************
00003 // sdObject.h
00004 //
00005 // This file contains the definition for the following classes.
00006 //
00007 //  sdObjectType
00008 //      This is a wrapper class for sdObjectTypeEnum. 
00009 // 
00010 //  sdObjectMemberIter
00011 //      This is a template class that supports some base functionality for
00012 //      iterating over members of sdObject. The members are sdAttribute objects
00013 //      and sdRelationshipBase objects.
00014 // 
00015 //  sdObjectAttributeIter
00016 //      This class is the iterator over sdAttributes of an sdObject and supports 
00017 //      iterating over attributes hierarchically.
00018 //
00019 //  sdObjectRelationshipIter
00020 //      This class is the iterator over sdRelationshipBase objects of an 
00021 //      sdObject and supports iterating over relationships hierarchically.
00022 //
00023 //  sdObject
00024 //      This class represents the schema data of a class. An object's schema
00025 //      consists of attributes, relationships etc.
00026 //  
00027 // *****************************************************************************
00028 // Except as specified in the OpenAccess terms of use of Cadence or Silicon
00029 // Integration Initiative, this material may not be copied, modified,
00030 // re-published, uploaded, executed, or distributed in any way, in any medium,
00031 // in whole or in part, without prior written permission from Cadence.
00032 //
00033 //                Copyright 2007 Cadence Design Systems, Inc.
00034 //                           All Rights Reserved.
00035 //
00036 //  $Author: icftcm $
00037 //  $Revision: #1 $
00038 //  $Date: 2007/03/20 $
00039 //  $State: Exp $
00040 // *****************************************************************************
00041 // *****************************************************************************
00042 
00043 
00044 
00045 #if !defined(sdObject_P)
00046 #define sdObject_P
00047 
00048 
00049 
00050 // *****************************************************************************
00051 // Nested includes
00052 // *****************************************************************************
00053 #include <vector>
00054 #include "sdBase.h"
00055 
00056 
00057 
00058 // *****************************************************************************
00059 // Declare and define types in the schema definition namespace.
00060 // *****************************************************************************
00061 BEGIN_SD_NAMESPACE
00062 
00063 
00064 
00065 // *****************************************************************************
00066 // Forward Public Class Declarations
00067 // *****************************************************************************
00068 class sdObject;
00069 class sdAttribute;
00070 class sdRelationshipBase;
00071 
00072 
00073 
00074 // *****************************************************************************
00075 // sdObjectMemberIter
00076 // *****************************************************************************
00077 template<class SDClass>
00078 class sdObjectMemberIter {
00079 public:
00080     const SDClass                                   *operator*() const;
00081     bool                                            operator==(const sdObjectMemberIter<SDClass> &iter) const;
00082     bool                                            operator!=(const sdObjectMemberIter<SDClass> &iter) const;
00083 
00084     sdObjectMemberIter<SDClass>                     &operator++();
00085 
00086 protected:
00087                                                     sdObjectMemberIter();
00088     virtual                                         ~sdObjectMemberIter();
00089 
00090     typedef std::vector<const SDClass*>             MemberVector;
00091     typedef typename MemberVector::const_iterator   MemberConstIter;
00092 
00093     MemberVector                                    m_vector;
00094     MemberConstIter                                 m_iter;
00095     bool                                            m_isEmpty;
00096 };
00097 
00098 
00099 
00100 // *****************************************************************************
00101 // sdObjectAttributeIter
00102 // *****************************************************************************
00103 class SD_DLL_API sdObjectAttributeIter : public sdObjectMemberIter<sdAttribute> {
00104 public:         
00105                             sdObjectAttributeIter();
00106                             sdObjectAttributeIter(const sdObject    *object,
00107                                                   bool              local);
00108     virtual                 ~sdObjectAttributeIter();
00109 
00110 private:
00111     void                    traverseHier(const sdObject *current,
00112                                          MemberVector   &objects);
00113 };
00114 
00115 
00116 
00117 // *****************************************************************************
00118 // sdObjectRelationshipIter
00119 // *****************************************************************************
00120 class SD_DLL_API sdObjectRelationshipIter : public sdObjectMemberIter<sdRelationshipBase> {
00121 public:         
00122                             sdObjectRelationshipIter();
00123                             sdObjectRelationshipIter(const sdObject *object,
00124                                                      bool           local);
00125     virtual                 ~sdObjectRelationshipIter();
00126 
00127 private:
00128     void                    traverseHier(const sdObject *current,
00129                                          MemberVector   &objects);
00130 };
00131 
00132 
00133 
00134 // *****************************************************************************
00135 // sdObject
00136 // *****************************************************************************
00137 class SD_DLL_API sdObject : public sdBase {
00138 public:         
00139     typedef std::vector<const sdObject*>            ObjectVector;
00140     typedef ObjectVector::const_iterator            ObjectConstIter;
00141 
00142                                                     sdObject(unsigned int       id,
00143                                                              const std::string  &name,
00144                                                              const std::string  &description,
00145                                                              bool               concrete,
00146                                                              sdNameSpace        *nameSpace,
00147                                                              const ObjectVector &superObjects);
00148     virtual                                         ~sdObject();
00149 
00150     unsigned int                                    getId() const;
00151     const std::string                               &getName() const;
00152     const std::string                               &getDescription() const;
00153     bool                                            isConcrete() const;
00154     const sdAttribute                               *getIdentifier() const;
00155     ObjectConstIter                                 beginSuperObject() const;
00156     ObjectConstIter                                 endSuperObject() const;
00157     ObjectConstIter                                 beginSubObject() const;
00158     ObjectConstIter                                 endSubObject() const;
00159     sdObjectAttributeIter                           beginAttribute(bool local) const;
00160     sdObjectAttributeIter                           endAttribute(bool local) const;
00161 
00162     sdObjectRelationshipIter                        beginRelationship(bool local) const;
00163     sdObjectRelationshipIter                        endRelationship(bool local) const;
00164 
00165     virtual void                                    accept(sdVisitor *visitor);
00166 
00167 private:
00168     void                                            addAttribute(sdAttribute *attribute);
00169     void                                            addRelationship(sdRelationshipBase *relationship);
00170     void                                            setIdentifier(sdAttribute *attribute);
00171     void                                            addSubObject(sdObject *subObject);
00172     void                                            removeSubObject(const sdObject *subObject);
00173 
00174     typedef std::vector<const sdAttribute*>         AttributeVector;
00175     typedef std::vector<const sdRelationshipBase*>  RelationshipVector;
00176 
00177     const unsigned int                              m_id;
00178     const std::string                               &m_name;
00179     const std::string                               m_description;
00180     const bool                                      m_isConcrete;
00181     AttributeVector                                 m_attributes;
00182     RelationshipVector                              m_relationships;
00183     const ObjectVector                              m_superObjects;
00184     ObjectVector                                    m_subObjects;
00185     sdAttribute                                     *m_identifier;
00186 
00187     friend class sdAttribute;
00188     friend class sdRelationship;
00189     friend class sdRelationshipSet;
00190     friend class sdObjectAttributeIter;
00191     friend class sdObjectRelationshipIter;
00192     friend class sdNameSpace;
00193 };
00194 
00195 
00196 
00197 END_SD_NAMESPACE
00198 
00199 #endif

Return to top of page