datafieldmap.hpp 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*##############################################################################
  2. HPCC SYSTEMS software Copyright (C) 2016 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 _DATAFIELDMAP_HPP__
  14. #define _DATAFIELDMAP_HPP__
  15. #pragma warning (disable : 4786)
  16. #include "jiface.hpp"
  17. #include "jstring.hpp"
  18. #include "jptree.hpp"
  19. #include "loggingcommon.hpp"
  20. class CLogField : public CInterface
  21. {
  22. StringAttr name;
  23. StringAttr mapTo;
  24. StringAttr type;
  25. StringAttr defaultValue;
  26. public:
  27. CLogField(const char* _name, const char* _mapTo, const char* _type)
  28. : name(_name), mapTo(_mapTo), type(_type) {};
  29. virtual ~CLogField() {};
  30. const char* getName() { return name.get(); };
  31. const char* getMapTo() { return mapTo.get(); };
  32. const char* getType() { return type.get(); };
  33. const char* getDefault() { return defaultValue.get(); };
  34. void setDefault(const char* value) { defaultValue.set(value); };
  35. };
  36. class CLogTable : public CInterface
  37. {
  38. StringAttr tableName;
  39. bool enableLogID;
  40. CIArrayOf<CLogField> logFields;
  41. public:
  42. CLogTable(const char* _tableName, bool _enableLogID) : tableName(_tableName), enableLogID(_enableLogID) {};
  43. virtual ~CLogTable() {};
  44. const char* getTableName() { return tableName.get(); };
  45. bool getEnableLogID() { return enableLogID; }
  46. void setTableName(const char* _tableName) { return tableName.set(_tableName); };
  47. void loadMappings(IPropertyTree& cfg);
  48. CIArrayOf<CLogField>& getLogFields() { return logFields; };
  49. };
  50. class CLogGroup : public CInterface, implements IInterface
  51. {
  52. StringAttr name;
  53. CIArrayOf<CLogTable> logTables;
  54. public:
  55. IMPLEMENT_IINTERFACE;
  56. CLogGroup(const char* _name) : name(_name) {};
  57. virtual ~CLogGroup() {};
  58. void loadMappings(IPropertyTree& cfg);
  59. CIArrayOf<CLogTable>& getLogTables() { return logTables; };
  60. };
  61. class CLogSource : public CInterface, implements IInterface
  62. {
  63. StringAttr name;
  64. StringAttr groupName;
  65. StringAttr dbName;
  66. public:
  67. IMPLEMENT_IINTERFACE;
  68. CLogSource(const char* _name, const char* _groupName, const char* _dbName)
  69. : name(_name), groupName(_groupName), dbName(_dbName) {};
  70. virtual ~CLogSource() {};
  71. const char* getName() { return name.get(); };
  72. const char* getGroupName() { return groupName.get(); };
  73. const char* getDBName() { return dbName.get(); };
  74. };
  75. extern LOGGINGCOMMON_API void ensureInputString(const char* input, bool lowerCase, StringBuffer& outputStr, int code, const char* msg);
  76. extern LOGGINGCOMMON_API void readLogGroupCfg(IPropertyTree* cfg, StringAttr& defaultLogGroup, MapStringToMyClass<CLogGroup>& logGroups);
  77. extern LOGGINGCOMMON_API void readLogSourceCfg(IPropertyTree* cfg, unsigned& logSourceCount, StringAttr& logSourcePath, MapStringToMyClass<CLogSource>& logGroups);
  78. #endif // !_DATAFIELDMAP_HPP__