fvrelate.hpp 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. #ifndef FVRELATE_HPP
  14. #define FVRELATE_HPP
  15. #include "fileview.hpp"
  16. #define CHEAP_UCHAR_DEF
  17. #ifdef _WIN32
  18. typedef wchar_t UChar;
  19. #else //_WIN32
  20. typedef unsigned short UChar;
  21. #endif //_WIN32
  22. typedef void (*stringFieldTransformerFunction)(unsigned & tgtLen, char * & tgt, unsigned srcLen, const char * src);
  23. typedef void (*utf8FieldTransformerFunction)(unsigned & tgtLen, char * & tgt, unsigned srcLen, const char * src);
  24. typedef void (*unicodeFieldTransformerFunction)(unsigned & tgtLen, UChar * & tgt, unsigned srcLen, const UChar * src);
  25. //Registry which can be used for registering transformations that can be included in the field lists.
  26. //It is also used for plugins required by dlls loaded to translate alien data types
  27. interface IViewTransformerRegistry
  28. {
  29. public:
  30. virtual void addFieldStringTransformer(const char * name, stringFieldTransformerFunction func) = 0;
  31. virtual void addFieldUtf8Transformer(const char * name, utf8FieldTransformerFunction func) = 0;
  32. virtual void addFieldUnicodeTransformer(const char * name, unicodeFieldTransformerFunction func) = 0;
  33. virtual void addPlugins(const char * pluginname) = 0;
  34. };
  35. extern FILEVIEW_API IViewTransformerRegistry & queryTransformerRegistry();
  36. //---------------------------------------------------------------------------
  37. struct ViewGatherOptions
  38. {
  39. inline ViewGatherOptions()
  40. {
  41. primaryDepth = 100;
  42. secondaryDepth = 100;
  43. maximumDepth = 200;
  44. kind = NULL; // defaults to link
  45. superDepth = 0;
  46. subDepth = 0;
  47. payload = NULL;
  48. requirePayload = false;
  49. explicitFilesOnly = false;
  50. }
  51. inline void setPayloadFilter(bool _value)
  52. {
  53. requirePayload = _value;
  54. payload = &requirePayload;
  55. }
  56. unsigned primaryDepth; // How many secondary->primary links to follow
  57. unsigned secondaryDepth; // How many primary->secondary links to follow
  58. unsigned maximumDepth; // maximum number of links
  59. const char * kind;
  60. unsigned superDepth; // How many super files to walk up
  61. unsigned subDepth;
  62. bool * payload;
  63. bool requirePayload;
  64. bool explicitFilesOnly; // If true, only files supplied to gatherFile/gatherFilePattern will be included
  65. };
  66. //---------------------------------------------------------------------------
  67. interface IFileTreeBrowser;
  68. interface IFileRelationship;
  69. interface IViewRelatedFile : public IInterface
  70. {
  71. virtual IDistributedFile * queryDistributedFile() const = 0;
  72. virtual INewResultSet * queryResultSet() = 0;
  73. };
  74. interface IViewRelatedFileIterator: public IIteratorOf<IViewRelatedFile> {};
  75. interface IViewRelation : public IInterface
  76. {
  77. virtual IFileRelationship * queryFileRelationship() const = 0;
  78. virtual unsigned numMappingFields() const = 0;
  79. virtual unsigned queryMappingField(unsigned whichMapping, bool needPrimary) const = 0;
  80. };
  81. interface IViewFileWeb : public IInterface
  82. {
  83. public:
  84. virtual void gatherWeb(const char * rootFilename, const ViewGatherOptions & options) = 0;
  85. virtual void gatherWeb(const char * rootFilename, IDistributedFile * alreadyResolved, const ViewGatherOptions & options) = 0;
  86. virtual void gatherWebFromPattern(const char * pattern, const ViewGatherOptions & options) = 0;
  87. virtual IViewRelatedFile * queryFile(unsigned i) = 0;
  88. virtual IViewRelatedFileIterator * getFileIterator() = 0;
  89. //Create a tree of related file cursors starting from a particular file.
  90. //Only files that can be reached will be added to the view tree.
  91. virtual IFileTreeBrowser * createBrowseTree(const char * browseRootFilename, bool isEfficient=true, unsigned maxRecursion=3) = 0;
  92. };
  93. interface IRelatedBrowseFile
  94. {
  95. public:
  96. virtual IViewRelatedFile * queryDefinition() const = 0;
  97. virtual IViewRelation * queryParentRelation() const = 0;
  98. virtual IRelatedBrowseFile * queryParent() const = 0;
  99. virtual IRelatedBrowseFile * queryChild(unsigned i) const = 0;
  100. virtual IResultSetCursor * queryCursor() = 0;
  101. };
  102. interface IFileTreeBrowser : public IInterface
  103. {
  104. virtual IRelatedBrowseFile * queryRootFile() = 0;
  105. virtual IResultSetFilter * queryRootFilter() = 0;
  106. };
  107. extern FILEVIEW_API IViewFileWeb * createViewFileWeb(IResultSetFactory & resultSetFactory, const char * cluster, IUserDescriptor *user);
  108. extern FILEVIEW_API void createERdiagram(StringBuffer & xgmml, IViewFileWeb & web);
  109. #endif