XRefFilesNode.hpp 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2012 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. // XRefFilesNode1.h: interface for the CXRefFilesNode class.
  14. //
  15. //////////////////////////////////////////////////////////////////////
  16. #ifndef XREFFILESNODE_HPP
  17. #define XREFFILESNODE_HPP
  18. #include "jiface.hpp"
  19. #include "jstring.hpp"
  20. #include "jptree.hpp"
  21. #include "rmtfile.hpp"
  22. #include "dadfs.hpp"
  23. #include "jlog.hpp"
  24. interface IUserDescriptor;
  25. interface IXRefFilesNode : extends IInterface
  26. {
  27. virtual StringBuffer& Serialize(StringBuffer& outStr) = 0;
  28. virtual void Deserialize(IPropertyTree& inTree) = 0;
  29. virtual bool RemovePhysical(const char* Partmask,IUserDescriptor* udesc,const char *clustername, StringBuffer &errstr) = 0;
  30. virtual bool AttachPhysical(const char* Partmask,IUserDescriptor* udesc,const char *clustername, StringBuffer &errstr) = 0;
  31. virtual bool RemoveLogical(const char* LogicalName,IUserDescriptor* udesc,const char *clustername,StringBuffer &errstr) = 0;
  32. virtual bool IsChanged() = 0;
  33. virtual void Commit() = 0;
  34. };
  35. class CXRefFilesNode : implements IXRefFilesNode, public CSimpleInterface
  36. {
  37. protected:
  38. bool m_bChanged;
  39. IPropertyTree& m_baseTree;
  40. Owned<IPropertyTree> m_DataTree;
  41. StringBuffer _data;
  42. StringBuffer prefixName;
  43. StringAttr rootdir;
  44. private:
  45. IPropertyTree* FindNode(const char* NodeName);
  46. IPropertyTree& getDataTree();
  47. void DirectoryFromMask(const char* Partmask,StringBuffer& directory);
  48. bool LogicalNameFromMask(const char* Partmask,StringBuffer& logicalName);
  49. bool RemoveTreeNode(const char* NodeName);
  50. bool RemoveRemoteFile(const char* fileName, const char* ipAddress);
  51. virtual void CleanTree(IPropertyTree& inTree){}
  52. public:
  53. IMPLEMENT_IINTERFACE_USING(CSimpleInterface);
  54. CXRefFilesNode(IPropertyTree& baseNode,const char* cluster, const char *rootdir);
  55. virtual ~CXRefFilesNode(){};
  56. virtual bool IsChanged();
  57. void Commit();
  58. virtual StringBuffer& Serialize(StringBuffer& outStr);
  59. virtual void Deserialize(IPropertyTree& inTree);
  60. virtual bool RemovePhysical(const char* Partmask,IUserDescriptor* udesc,const char *clustername,StringBuffer &errstr);
  61. virtual bool RemoveLogical(const char* LogicalName,IUserDescriptor* udesc,const char *clustername,StringBuffer &errstr);
  62. virtual bool AttachPhysical(const char* Partmask,IUserDescriptor* udesc,const char *clustername,StringBuffer &errstr);
  63. };
  64. class CXRefOrphanFilesNode : public CXRefFilesNode
  65. {
  66. public:
  67. CXRefOrphanFilesNode(IPropertyTree& baseNode,const char* cluster,const char* rootdir);
  68. void CleanTree(IPropertyTree& inTree);
  69. };
  70. #endif // !XREFFILESNODE