00001 // ***************************************************************************** 00002 // ***************************************************************************** 00003 // srBase.h 00004 // 00005 // This file contains the definition of the schema representation classes. 00006 // 00007 // srBase 00008 // The base class for the schema representation classes. It defines the 00009 // interfaces necessary for all schema representation classes. 00010 // 00011 // srValueBase 00012 // The srValue base class. The application will derive from this base class 00013 // for each value defined in the application's sdNameSpace. The values are 00014 // referenced by the attributes. 00015 // 00016 // srAttributeBase 00017 // The srAttribute base class. The application will derive from this base 00018 // class for each attribute value defined in the application's sdNameSpace. 00019 // 00020 // srRelationshipBase 00021 // The srRelationship base class. There are 2 specialized representation 00022 // to handle 1 to 1 relationship and 1 to N relationship. 00023 // 00024 // srObjectRef 00025 // srObjectRef encapsulates the definition and representation to an opaque 00026 // object pointer. 00027 // 00028 // srObjectState 00029 // srObjectState contains the complete state of a specific object defined 00030 // in the schema definition, including all the attributes and relationships 00031 // of the object. 00032 // 00033 // sr1to1Relationship 00034 // sr1to1Relationship captures a specific 1 to 1 relationship of the 00035 // application. The relationship uses srObjectRef to store the references 00036 // to the specific objects in the 1 to 1 relationship. 00037 // 00038 // sr1toNRelationship 00039 // sr1toNRelationship captures a specific 1 to N relationship of the 00040 // application. The relationship uses srObjectRef to store the references 00041 // to the specific objects in the 1 to N relationship. 00042 // 00043 // ***************************************************************************** 00044 // Except as specified in the OpenAccess terms of use of Cadence or Silicon 00045 // Integration Initiative, this material may not be copied, modified, 00046 // re-published, uploaded, executed, or distributed in any way, in any medium, 00047 // in whole or in part, without prior written permission from Cadence. 00048 // 00049 // Copyright 2007 Cadence Design Systems, Inc. 00050 // All Rights Reserved. 00051 // 00052 // $Author: jaideep $ 00053 // $Revision: 1.3 $ 00054 // $Date: 2007/03/09 16:31:27 $ 00055 // $State: Exp $ 00056 // ***************************************************************************** 00057 // ***************************************************************************** 00058 00059 00060 00061 #if !defined(srBase_P) 00062 #define srBase_P 00063 00064 00065 00066 // ***************************************************************************** 00067 // Nested includes 00068 // ***************************************************************************** 00069 #include <vector> 00070 #include <map> 00071 #include <string> 00072 #include "oaCommonIntrusivePtr.h" 00073 #include "sdValue.h" 00074 #include "sdAttribute.h" 00075 #include "sdRelationship.h" 00076 #include "sdObject.h" 00077 #include "srBaseTypes.h" 00078 00079 00080 00081 // ***************************************************************************** 00082 // Declare and define types in the Schema namespace. 00083 // ***************************************************************************** 00084 BEGIN_SR_NAMESPACE 00085 00086 00087 00088 // ***************************************************************************** 00089 // Forward Public Class Declarations 00090 // ***************************************************************************** 00091 class srVisitorMgr; 00092 00093 00094 00095 // ***************************************************************************** 00096 // srBase 00097 // ***************************************************************************** 00098 class SR_DLL_API srBase { 00099 public: 00100 typedef srBase *SPtr; 00101 00102 srBase(); 00103 virtual ~srBase(); 00104 00105 virtual void accept(srVisitorMgr &visitor) = 0; 00106 00107 void addRef() const; 00108 void release() const; 00109 00110 private: 00111 srBase(const srBase ©); 00112 srBase &operator=(const srBase &rhs); 00113 00114 mutable unsigned int m_refCount; 00115 }; 00116 00117 00118 00119 // ***************************************************************************** 00120 // srValueBase 00121 // ***************************************************************************** 00122 class SR_DLL_API srValueBase : public srBase { 00123 public: 00124 typedef srValueBase *SPtr; 00125 00126 srValueBase(const sd::sdValue *def); 00127 virtual ~srValueBase(); 00128 00129 const sd::sdValue *getDef() const; 00130 00131 protected: 00132 void *m_data; 00133 00134 private: 00135 srValueBase(const srValueBase ©); 00136 srValueBase &operator=(const srValueBase &rhs); 00137 }; 00138 00139 00140 00141 // ***************************************************************************** 00142 // srObjectRef 00143 // ***************************************************************************** 00144 class SR_DLL_API srObjectRef : public srBase { 00145 public: 00146 typedef srObjectRef *SPtr; 00147 typedef const srObjectRef *CSPtr; 00148 00149 srObjectRef(const sd::sdObject *def, 00150 void *object); 00151 virtual ~srObjectRef(); 00152 00153 virtual void accept(srVisitorMgr &visitor); 00154 00155 const sd::sdObject *getDef() const; 00156 void *getObject() const; 00157 00158 void setObject(void *object); 00159 00160 private: 00161 srObjectRef(const srObjectRef ©); 00162 srObjectRef &operator=(const srObjectRef &rhs); 00163 00164 void *m_data; 00165 }; 00166 00167 00168 00169 00170 00171 00172 // ***************************************************************************** 00173 // srRelationshipBase 00174 // ***************************************************************************** 00175 class SR_DLL_API srRelationshipBase : public srBase { 00176 public: 00177 typedef srRelationshipBase *SPtr; 00178 00179 virtual ~srRelationshipBase(); 00180 00181 const sd::sdRelationshipBase *getDef() const; 00182 00183 sr::srObjectRef::CSPtr getFrom() const; 00184 00185 protected: 00186 srRelationshipBase(const sd::sdRelationshipBase *def=0, 00187 const srObjectRef::CSPtr from=0); 00188 00189 void *m_data; 00190 00191 private: 00192 srRelationshipBase(const srRelationshipBase ©); 00193 srRelationshipBase &operator=(const srRelationshipBase &rhs); 00194 }; 00195 00196 00197 00198 // ***************************************************************************** 00199 // srAttributeBase 00200 // ***************************************************************************** 00201 class SR_DLL_API srAttributeBase : public srBase { 00202 public: 00203 typedef srAttributeBase *SPtr; 00204 00205 srAttributeBase(const sd::sdAttribute *def, 00206 const srObjectRef::SPtr object); 00207 virtual ~srAttributeBase(); 00208 00209 srObjectRef::CSPtr getObject() const; 00210 const sd::sdAttribute *getDef() const; 00211 00212 protected: 00213 void *m_data; 00214 00215 private: 00216 srAttributeBase(const srAttributeBase ©); 00217 srAttributeBase &operator=(const srAttributeBase &rhs); 00218 }; 00219 00220 00221 00222 // ***************************************************************************** 00223 // sr1to1Relationship 00224 // ***************************************************************************** 00225 class SR_DLL_API sr1to1Relationship : public srRelationshipBase { 00226 public: 00227 typedef sr1to1Relationship *SPtr; 00228 00229 sr1to1Relationship(const sd::sdRelationshipBase *def, 00230 const srObjectRef::SPtr from, 00231 const srObjectRef::SPtr to); 00232 virtual ~sr1to1Relationship(); 00233 00234 virtual void accept(srVisitorMgr &visitor); 00235 00236 srObjectRef::CSPtr getTo() const; 00237 00238 void setTo(const srObjectRef::SPtr object); 00239 00240 private: 00241 sr1to1Relationship(const sr1to1Relationship ©); 00242 sr1to1Relationship &operator=(const sr1to1Relationship &rhs); 00243 00244 void *m_data; 00245 }; 00246 00247 00248 00249 // ***************************************************************************** 00250 // sr1toNRelationship 00251 // ***************************************************************************** 00252 class SR_DLL_API sr1toNRelationship : public srRelationshipBase { 00253 public: 00254 typedef sr1toNRelationship *SPtr; 00255 typedef std::vector<srObjectRef::SPtr> ObjectRefVec; 00256 typedef ObjectRefVec::const_iterator ConstIterator; 00257 00258 sr1toNRelationship(const sd::sdRelationshipBase *def, 00259 const srObjectRef::SPtr from, 00260 const ObjectRefVec &to); 00261 virtual ~sr1toNRelationship(); 00262 00263 virtual void accept(srVisitorMgr &visitor); 00264 00265 ConstIterator beginToObject() const; 00266 ConstIterator endToObject() const; 00267 00268 void setTo(const ObjectRefVec &objects); 00269 00270 private: 00271 sr1toNRelationship(const sr1toNRelationship ©); 00272 sr1toNRelationship &operator=(const sr1toNRelationship &rhs); 00273 00274 void *m_data; 00275 }; 00276 00277 00278 00279 // ***************************************************************************** 00280 // srSDEnumLess 00281 // ***************************************************************************** 00282 template<class T> 00283 class srSDEnumLess { 00284 public: 00285 bool operator()(const T *lhs, 00286 const T *rhs) const; 00287 }; 00288 00289 00290 00291 // ***************************************************************************** 00292 // srObjectState 00293 // ***************************************************************************** 00294 class SR_DLL_API srObjectState : public srBase { 00295 public: 00296 typedef srObjectState *SPtr; 00297 typedef std::map<const sd::sdAttribute*, srAttributeBase::SPtr, srSDEnumLess<sd::sdAttribute> > AttributeMap; 00298 typedef std::map<const sd::sdRelationshipBase*, srRelationshipBase::SPtr, srSDEnumLess<sd::sdRelationshipBase> > RelationshipMap; 00299 typedef std::pair<const sd::sdAttribute*, srAttributeBase::SPtr> AttributePair; 00300 typedef std::pair<const sd::sdRelationshipBase*, srRelationshipBase::SPtr> RelationshipPair; 00301 00302 typedef AttributeMap::const_iterator AttributeConstIter; 00303 typedef RelationshipMap::const_iterator RelationshipConstIter; 00304 00305 srObjectState(const sd::sdObject *def, 00306 const AttributeMap &attributes, 00307 const RelationshipMap &relationships); 00308 virtual ~srObjectState(); 00309 00310 virtual void accept(srVisitorMgr &visitor); 00311 00312 const sd::sdObject *getDef() const; 00313 AttributeConstIter beginAttribute() const; 00314 AttributeConstIter endAttribute() const; 00315 RelationshipConstIter beginRelationship() const; 00316 RelationshipConstIter endRelationship() const; 00317 00318 void addAttribute(srAttributeBase::SPtr attribute, 00319 bool overwrite = false); 00320 void addRelationship(srRelationshipBase::SPtr relationship, 00321 bool overwrite = false); 00322 void setAttributes(const AttributeMap &attributes); 00323 void setRelationships(const RelationshipMap &relationships); 00324 00325 private: 00326 typedef std::pair<AttributeMap::iterator, bool> AttributeCheck; 00327 typedef std::pair<RelationshipMap::iterator, bool> RelationshipCheck; 00328 00329 srObjectState(const srObjectState ©); 00330 srObjectState &operator=(const srObjectState &rhs); 00331 00332 void *m_data; 00333 }; 00334 00335 00336 00337 END_SR_NAMESPACE 00338 00339 #endif 00340
Copyright © 2002 - 2010 Cadence Design Systems, Inc.
All Rights Reserved.