ComponentBase.hpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2018 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. #ifndef _COMPONENTBASE_HPP_
  14. #define _COMPONENTBASE_HPP_
  15. #include "EnvHelper.hpp"
  16. namespace ech
  17. {
  18. class ComponentBase : public CInterface, implements IConfigComp
  19. {
  20. public:
  21. ComponentBase(const char* name, EnvHelper * envHelper);
  22. virtual ~ComponentBase(){};
  23. virtual void create(IPropertyTree *params) {};
  24. virtual unsigned add(IPropertyTree *params) { return 0; };
  25. virtual void modify(IPropertyTree *params);
  26. virtual void remove(IPropertyTree *params);
  27. IMPLEMENT_IINTERFACE;
  28. virtual IPropertyTree * cloneComponent(IPropertyTree *params);
  29. virtual void resolveSelector(const char* selector, const char* key, StringBuffer& out);
  30. const char* getAttributeFromParams(IPropertyTree *attrs, const char* attrName, const char* defaultValue);
  31. bool validateAttribute(const char* xpath, const char* name, const char* value);
  32. bool validateAttributes(const char* xPath, IPropertyTree *pAttrs);
  33. IPropertyTree * getCompTree(IPropertyTree *params);
  34. IPropertyTree * updateNode(IPropertyTree* pNode, IPropertyTree *pAttrs, StringArray *exludeList = NULL);
  35. IPropertyTree * createNode(IPropertyTree *pAttrs);
  36. // If allow multiple same child tag name it need another parameter. Currently only allow one.
  37. // If already exists it will only update attributes instead of creating a new node
  38. IPropertyTree * createChildrenNodes(IPropertyTree *parent, IPropertyTree *children);
  39. IPropertyTree * removeAttributes(IPropertyTree* pNode, IPropertyTree *pAttrs, StringArray *exludeList = NULL);
  40. IPropertyTree * getNodeByAttributes(IPropertyTree* parent, const char* xpath, IPropertyTree *pAttrs);
  41. bool isNodeMatch(IPropertyTree *pNode, IPropertyTree *pAttrs);
  42. protected:
  43. Mutex mutex;
  44. EnvHelper * m_envHelper;
  45. StringBuffer m_name;
  46. };
  47. }
  48. #endif