SchemaMapManager.hpp 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2015 HPCC Systems®.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. ############################################################################## */
  13. #include "jhash.hpp"
  14. #include "jhash.ipp"
  15. #include "jlog.hpp"
  16. #include "SchemaCommon.hpp"
  17. #include <set>
  18. #ifndef _SCHEMA_MAP_MANAGER_HPP_
  19. #define _SCHEMA_MAP_MANAGER_HPP_
  20. namespace CONFIGURATOR
  21. {
  22. class CSchema;
  23. class CAttribute;
  24. class CAttributeGroup;
  25. class CSimpleType;
  26. class CComplexType;
  27. class CAttributeGroup;
  28. class CAttribute;
  29. class CRestriction;
  30. class CElementArray;
  31. class CElement;
  32. class CKey;
  33. class CSchemaMapManager
  34. {
  35. public:
  36. CSchemaMapManager();
  37. virtual ~CSchemaMapManager();
  38. CSchema* getSchemaForXSD(const char* pComponent);
  39. void setSchemaForXSD(const char* pComponent, CSchema *pSchema);
  40. CSimpleType* getSimpleTypeWithName(const char* pName);
  41. void setSimpleTypeWithName(const char* pName, CSimpleType *pSimpleType);
  42. CComplexType* getComplexTypeWithName(const char* pName);
  43. void setComplexTypeWithName(const char* pName, CComplexType *pComplexType);
  44. CComplexType* getComplexTypeFromXPath(const char *pXPath);
  45. CAttributeGroup *getAttributeGroup(const char* pName);
  46. void setAttributeGroupTypeWithName(const char* pName, CAttributeGroup *pAttributeGroup);
  47. CAttributeGroup* getAttributeGroupFromXPath(const char *pXPath);
  48. CElement* getElementWithName(const char* pName);
  49. void setElementWithName(const char* pName, CElement *pElement);
  50. void addMapOfXPathToAttribute(const char* pXPath, CAttribute *pAttribute);
  51. void removeMapOfXPathToAttribute(const char* pXPath);
  52. CAttribute* getAttributeFromXPath(const char* pXPath);
  53. void addMapOfXPathToRestriction(const char*pXPath, CRestriction *pRestriction);
  54. void removeMapOfXPathToRestriction(const char*pXPath);
  55. CRestriction* getRestrictionFromXPath(const char* pXPath);
  56. void addMapOfXSDXPathToElementArray(const char* pXPath, CElementArray *pElementArray);
  57. void removeMapOfXSDXPathToElementArray(const char* pXPath);
  58. CElementArray* getElementArrayFromXSDXPath(const char* pXPath);
  59. void addMapOfXPathToElement(const char* pXPath, CElement *pElement, bool bIsTopLevelElement = false);
  60. void removeMapOfXPathToElement(const char* pXPath);
  61. CElement* getElementFromXPath(const char *pXPath);
  62. void addMapOfXPathToElementArray(const char* pXPath, CElementArray *pElementArray);
  63. void removeMapOfXPathToElementArray(const char* pXPath);
  64. CElementArray* getElementArrayFromXPath(const char *pXPath);
  65. void addMapOfXSDXPathToElement(const char* pXPath, CElement *pElement);
  66. CElement* getElementFromXSDXPath(const char *pXPath) const;
  67. void addMapOfXSDXPathToKey(const char* pXPath, CKey *pKey);
  68. CKey* getKeyFromXSDXPath(const char *pXPath) const;
  69. int getNumberOfComponents() const;
  70. CElement* getComponent(int index);
  71. int getIndexOfElement(const CElement *pElem);
  72. enum NODE_TYPES getEnumFromTypeName(const char *pTypeName) const;
  73. const char* getTypeNameFromEnum(enum NODE_TYPES, bool bForDump = false) const;
  74. bool isNodeExcluded(enum NODE_TYPES nodeType) const;
  75. void addExludedNode(enum NODE_TYPES nodeType);
  76. protected:
  77. typedef MapStringTo<CSchema*> MapStringToCSchema;
  78. Owned<MapStringToCSchema> m_pSchemaPtrMap;
  79. typedef MapStringTo<CSimpleType*> MapStringToCSimpleType;
  80. Owned<MapStringToCSimpleType> m_pSimpleTypePtrMap;
  81. typedef MapStringTo<CComplexType*> MapStringToCComplexType;
  82. Owned<MapStringToCComplexType> m_pComplexTypePtrsMap;
  83. typedef MapStringTo<CAttributeGroup*> MapStringToCAttributeGroup;
  84. Owned<MapStringToCAttributeGroup> m_pAttributeGroupTypePtrsMap;
  85. typedef MapStringTo<CAttribute*> MapStringToCAttribute;
  86. Owned<MapStringToCAttribute> m_pAttributePtrsMap;
  87. typedef MapStringTo<CRestriction*> MapStringToCRestriction;
  88. Owned<MapStringToCRestriction> m_pRestrictionPtrsMap;
  89. typedef MapStringTo<CElement*> MapStringToCElement;
  90. Owned<MapStringToCElement> m_pElementPtrsMap;
  91. Owned<MapStringToCElement> m_pElementNamePtrsMap;
  92. Owned<MapStringToCElement> m_pXSDToElementPtrsMap;
  93. typedef MapStringTo<CElementArray*> MapStringToCElementArray;
  94. Owned<MapStringToCElementArray> m_pElementArrayPtrsMap;
  95. const char* m_enumArray[XSD_ERROR][2];
  96. typedef MapStringTo<enum NODE_TYPES> MapStringToNodeTypeEnum;
  97. Owned<MapStringToNodeTypeEnum> m_pStringToEnumMap;
  98. typedef MapStringTo<CKey*> MapStringToCKey;
  99. Owned<MapStringToCKey> m_pStringToKeyPtrsMap;
  100. typedef MapStringTo<CXSDNodeBase*> MapStringToCNodeBase;
  101. Owned<MapStringToCNodeBase> m_pStringToNodeBaseMap;
  102. struct STypeStrings
  103. {
  104. const char *pXSDTypeString;
  105. const char *pDumpTypeString;
  106. };
  107. std::set<enum NODE_TYPES> m_setOfExludedNodeTypes;
  108. private:
  109. };
  110. }
  111. #endif // _SCHEMA_MAP_MANAGER_HPP_