From d62046145e4b4ad4a3a9dfa71f639bf4223574f6 Mon Sep 17 00:00:00 2001
From: Neil Graham <neilg@apache.org>
Date: Fri, 10 Oct 2003 18:37:51 +0000
Subject: [PATCH] update XSModel and XSObject interface so that IDs can be used
 to query components in XSModels, and so that those IDs can be recovered from
 components

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@175274 13f79535-47bb-0310-9956-ffa450edef68
---
 src/xercesc/framework/psvi/XSModel.cpp  | 43 ++++++++++++++++++++++++-
 src/xercesc/framework/psvi/XSModel.hpp  | 37 +++++++++++++++++++--
 src/xercesc/framework/psvi/XSObject.cpp | 14 ++++++++
 src/xercesc/framework/psvi/XSObject.hpp | 11 +++++++
 4 files changed, 101 insertions(+), 4 deletions(-)

diff --git a/src/xercesc/framework/psvi/XSModel.cpp b/src/xercesc/framework/psvi/XSModel.cpp
index 6431ba139..334faaa72 100644
--- a/src/xercesc/framework/psvi/XSModel.cpp
+++ b/src/xercesc/framework/psvi/XSModel.cpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.2  2003/10/10 18:37:51  neilg
+ * update XSModel and XSObject interface so that IDs can be used to query components in XSModels, and so that those IDs can be recovered from components
+ *
  * Revision 1.1  2003/09/16 14:33:36  neilg
  * PSVI/schema component model classes, with Makefile/configuration changes necessary to build them
  *
@@ -65,7 +68,30 @@
 
 XERCES_CPP_NAMESPACE_BEGIN
 
-XSModel::XSModel( MemoryManager* const manager ):  
+/**
+  * The constructor to be used wen a grammar pool contains all needed info
+  *
+  * @param grammarPool  the grammar pool containing the underlying data structures
+  * @param  manager     The configurable memory manager
+  */
+XSModel::XSModel( XMLGrammarPool *grammarPool
+            , MemoryManager* const manager ):
+        fMemoryManager(manager)
+{
+}
+
+/**
+  * The constructor to be used when the XSModel must represent all
+  * components in the union of an existing XSModel and a newly-created
+  * Grammar
+  *
+  * @param baseModel  the XSModel upon which this one is based
+  * @param  grammar  the newly-created grammar whose components are to be merged
+  * @param  manager     The configurable memory manager
+  */
+XSModel::XSModel( XSModel *baseModel
+            , Grammar *grammar
+            , MemoryManager* const manager ):
         fMemoryManager(manager)
 {
 }
@@ -227,6 +253,21 @@ XSNotationDeclaration *XSModel::getNotationDeclaration(const XMLCh *name
     return 0;
 }
 
+/**
+  * Optional.  Return a component given a component type and a unique Id.  
+  * May not be supported for all component types.
+  * @param compId unique Id of the component within its type
+  * @param compType type of the component
+  * @return the component of the given type with the given Id, or 0
+  * if no such component exists or this is unsupported for
+  * this type of component.
+  */
+XSObject *XSModel::getXSObjectById(unsigned int  compId
+            , XSConstants::COMPONENT_TYPE compType)
+{
+    return 0;
+}
+
 XERCES_CPP_NAMESPACE_END
 
 
diff --git a/src/xercesc/framework/psvi/XSModel.hpp b/src/xercesc/framework/psvi/XSModel.hpp
index 2d1e1a1f2..1e6df4500 100644
--- a/src/xercesc/framework/psvi/XSModel.hpp
+++ b/src/xercesc/framework/psvi/XSModel.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.2  2003/10/10 18:37:51  neilg
+ * update XSModel and XSObject interface so that IDs can be used to query components in XSModels, and so that those IDs can be recovered from components
+ *
  * Revision 1.1  2003/09/16 14:33:36  neilg
  * PSVI/schema component model classes, with Makefile/configuration changes necessary to build them
  *
@@ -83,6 +86,8 @@ XERCES_CPP_NAMESPACE_BEGIN
  */
 
 // forward declarations
+class Grammar;
+class XMLGrammarPool;
 class XSAnnotation;
 class XSAttributeDeclaration;
 class XSAttributeGroupDefinition;
@@ -102,12 +107,26 @@ public:
     //@{
 
     /**
-      * The default constructor 
+      * The constructor to be used wen a grammar pool contains all needed info
       *
+      * @param grammarPool  the grammar pool containing the underlying data structures
       * @param  manager     The configurable memory manager
       */
-    XSModel( 
-                MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
+    XSModel( XMLGrammarPool *grammarPool
+                , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
+
+    /**
+      * The constructor to be used when the XSModel must represent all
+      * components in the union of an existing XSModel and a newly-created
+      * Grammar
+      *
+      * @param baseModel  the XSModel upon which this one is based
+      * @param  grammar  the newly-created grammar whose components are to be merged
+      * @param  manager     The configurable memory manager
+      */
+    XSModel( XSModel *baseModel
+                , Grammar *grammar
+                , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
 
     //@};
 
@@ -232,6 +251,18 @@ public:
     XSNotationDeclaration *getNotationDeclaration(const XMLCh *name
             , const XMLCh *compNamespace);
 
+    /**
+      * Optional.  Return a component given a component type and a unique Id.  
+      * May not be supported for all component types.
+      * @param compId unique Id of the component within its type
+      * @param compType type of the component
+      * @return the component of the given type with the given Id, or 0
+      * if no such component exists or this is unsupported for
+      * this type of component.
+      */
+    XSObject *getXSObjectById(unsigned int  compId
+                , XSConstants::COMPONENT_TYPE compType);
+
     // @}
 
     //----------------------------------
diff --git a/src/xercesc/framework/psvi/XSObject.cpp b/src/xercesc/framework/psvi/XSObject.cpp
index c061cad64..599be4517 100644
--- a/src/xercesc/framework/psvi/XSObject.cpp
+++ b/src/xercesc/framework/psvi/XSObject.cpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.3  2003/10/10 18:37:51  neilg
+ * update XSModel and XSObject interface so that IDs can be used to query components in XSModels, and so that those IDs can be recovered from components
+ *
  * Revision 1.2  2003/09/17 17:45:37  neilg
  * remove spurious inlines; hopefully this will make Solaris/AIX compilers happy.
  *
@@ -95,6 +98,17 @@ XSNamespaceItem *XSObject::getNamespaceItem()
     return 0;
 }
 
+/**
+  * Optional.  return a unique identifier for a component within this XSModel, to
+  * optimize querying.  May not be defined for all component types.
+  * @return id unique for this type of component within this XSModel
+  * or 0 to indicate that this is unsupported for this type of component.
+  */
+inline unsigned int XSObject::getId() const
+{
+    return 0;
+}
+
 XERCES_CPP_NAMESPACE_END
 
 
diff --git a/src/xercesc/framework/psvi/XSObject.hpp b/src/xercesc/framework/psvi/XSObject.hpp
index 448e72a53..c504702d3 100644
--- a/src/xercesc/framework/psvi/XSObject.hpp
+++ b/src/xercesc/framework/psvi/XSObject.hpp
@@ -56,6 +56,9 @@
 
 /*
  * $Log$
+ * Revision 1.2  2003/10/10 18:37:51  neilg
+ * update XSModel and XSObject interface so that IDs can be used to query components in XSModels, and so that those IDs can be recovered from components
+ *
  * Revision 1.1  2003/09/16 14:33:36  neilg
  * PSVI/schema component model classes, with Makefile/configuration changes necessary to build them
  *
@@ -134,6 +137,14 @@ public:
      */
     virtual XSNamespaceItem *getNamespaceItem();
 
+    /**
+      * Optional.  Return a unique identifier for a component within this XSModel, to
+      * optimize querying.  May not be defined for all types of component.
+      * @return id unique for this type of component within this XSModel or 0
+      *     to indicate that this is not supported for this type of component.
+      */
+    virtual unsigned int getId() const;
+
     //@}
 
     //----------------------------------
-- 
GitLab