hqlcppc.hpp 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  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 __HQLCPPC_HPP_
  14. #define __HQLCPPC_HPP_
  15. #include "eclhelper.hpp"
  16. //---------------------------------------------------------------------------
  17. class HqlCppTranslator;
  18. class BoundRow;
  19. class CHqlBoundExpr;
  20. class CHqlBoundTarget;
  21. class SizeStruct;
  22. interface IReferenceSelector;
  23. interface IHqlDelayedCodeGenerator;
  24. struct ReadAheadState;
  25. //external public interface into the members of a record...
  26. class HQLCPP_API AColumnInfo : public MappingBase
  27. {
  28. public:
  29. virtual void buildAddress(HqlCppTranslator & translator, BuildCtx & ctx, IReferenceSelector * selector, CHqlBoundExpr & bound) = 0;
  30. virtual void buildAssign(HqlCppTranslator & translator, BuildCtx & ctx, IReferenceSelector * selector, const CHqlBoundTarget & target) = 0;
  31. virtual void buildSizeOf(HqlCppTranslator & translator, BuildCtx & ctx, IReferenceSelector * selector, CHqlBoundExpr & bound) = 0;
  32. virtual void buildOffset(HqlCppTranslator & translator, BuildCtx & ctx, IReferenceSelector * selector, CHqlBoundExpr & bound) = 0;
  33. virtual void buildClear(HqlCppTranslator & translator, BuildCtx & ctx, IReferenceSelector * selector, int direction) = 0;
  34. // virtual bool buildCount(HqlCppTranslator & translator, BuildCtx & ctx, IReferenceSelector * selector, CHqlBoundExpr & bound) = 0;
  35. virtual void buildExpr(HqlCppTranslator & translator, BuildCtx & ctx, IReferenceSelector * selector, CHqlBoundExpr & bound) = 0;
  36. virtual size32_t getContainerTrailingFixed() = 0;
  37. virtual bool hasFixedOffset() = 0;
  38. virtual bool isConditional() = 0;
  39. virtual bool isFixedSize() = 0;
  40. virtual AColumnInfo * lookupColumn(IHqlExpression * search) = 0;
  41. virtual ITypeInfo * queryType() const = 0;
  42. virtual bool requiresTemp() = 0;
  43. virtual bool modifyColumn(HqlCppTranslator & translator, BuildCtx & ctx, IReferenceSelector * selector, IHqlExpression * value, node_operator op) = 0;
  44. virtual void setColumn(HqlCppTranslator & translator, BuildCtx & ctx, IReferenceSelector * selector, IHqlExpression * value) = 0;
  45. virtual void setRow(HqlCppTranslator & translator, BuildCtx & ctx, IReferenceSelector * selector, IReferenceSelector * value) = 0;
  46. virtual void buildDeserialize(HqlCppTranslator & translator, BuildCtx & ctx, IReferenceSelector * selector, IHqlExpression * helper, _ATOM serializeForm) = 0;
  47. virtual void buildSerialize(HqlCppTranslator & translator, BuildCtx & ctx, IReferenceSelector * selector, IHqlExpression * helper, _ATOM serializeForm) = 0;
  48. virtual bool prepareReadAhead(HqlCppTranslator & translator, ReadAheadState & state) = 0;
  49. virtual bool buildReadAhead(HqlCppTranslator & translator, BuildCtx & ctx, ReadAheadState & state) = 0;
  50. };
  51. class HQLCPP_API ABoundActivity : public CInterface, public IInterface
  52. {
  53. public:
  54. ABoundActivity(IHqlExpression * _dataset, IHqlExpression * _bound, unsigned _activityid, unsigned _containerid, unsigned _graphId, ThorActivityKind _kind)
  55. : represents(_dataset), bound(_bound), activityId(_activityid), containerId(_containerid), graphId(_graphId)
  56. {
  57. outputCount = 0;
  58. kind = _kind;
  59. }
  60. IMPLEMENT_IINTERFACE
  61. inline IHqlExpression * queryBound() const { return bound; }
  62. inline IHqlExpression * queryDataset() const { return represents; }
  63. inline unsigned queryActivityId() const { return activityId; }
  64. inline ThorActivityKind queryActivityKind() const { return kind; }
  65. inline unsigned queryContainerId() const { return containerId; }
  66. inline unsigned queryGraphId() const { return graphId; }
  67. inline unsigned nextOutputCount() { return outputCount++; }
  68. IHqlDelayedCodeGenerator * createOutputCountCallback();
  69. void updateActivityKind(ThorActivityKind newKind) { kind = newKind; }
  70. private:
  71. HqlExprAttr represents;
  72. HqlExprAttr bound;
  73. unsigned activityId;
  74. unsigned containerId;
  75. unsigned graphId;
  76. unsigned outputCount;
  77. ThorActivityKind kind;
  78. };
  79. class HQLCPP_API ActivityAssociation : public HqlExprAssociation
  80. {
  81. public:
  82. ActivityAssociation(IHqlExpression * _dataset, ABoundActivity * _activity) : HqlExprAssociation(_dataset) { activity.set(_activity); }
  83. virtual AssocKind getKind() { return AssocActivity; }
  84. public:
  85. Linked<ABoundActivity> activity;
  86. };
  87. interface IGenDatasetIterator : public IInterface
  88. {
  89. public:
  90. virtual void buildDeclare(HqlCppTranslator & translator, BuildCtx & ctx) = 0;
  91. virtual void buildFirst(HqlCppTranslator & translator, BuildCtx & ctx) = 0;
  92. virtual void buildIsValid(HqlCppTranslator & translator, BuildCtx & ctx, CHqlBoundExpr & bound) = 0;
  93. virtual void buildIterateLoop(HqlCppTranslator & translator, BuildCtx & ctx) = 0;
  94. virtual void buildNext(HqlCppTranslator & translator, BuildCtx & ctx) = 0;
  95. };
  96. extern HQLCPP_API IHqlExpression * convertAddressToValue(IHqlExpression * address, ITypeInfo * columnType);
  97. #endif