#pragma once #include "DbBlockAction.h" /** \details Lookup action is a block action that stores a table of values. Each column of that table corresponds to a parameter Usual (non-lookup) parameters may be only input. OdDbBlockLookupParameter may be an output. During direct lookup output parameter value is calculated iterating the table rows. If all the current parameter values match corresponding input value in a row then this row is active and the output parameters are assigned the values from that row. Reverse lookup finds the row corresponding to the given lookup parameter value and assigns all the "input" parameters values from that row */ class DYNBLOCKS_EXPORT OdDbBlockLookupAction : public OdDbBlockAction { public: /** \details This class describes a column in a lookup table */ struct DYNBLOCKS_EXPORT ColumnInfo { /** \details Id of the parameter for that column */ OdDbEvalNodeId m_nParameterId = OdDbEvalGraph::kNullNodeId; /** \details Value type. May be kDwgReal, kDwgInt16 or kDwgText */ DwgDataType m_DataType = kDwgNull; /** \details Units type. */ OdDbDynBlockReferenceProperty::UnitsType m_nUnitType = OdDbDynBlockReferenceProperty::kNoUnits; /** \details If that column is a lookup column */ bool m_bOutputColumn = false; /** \details If that column may serve both as input and lookup */ bool m_bInvertible = true; /** \details Default value, if no matching row was found */ OdString m_sUnmatched; /** \details Parameter connection string, to get value. (e.g. "UpdatedDistanceX") */ OdString m_sConnection; /** \details Currently active lookup value (runtime only). */ OdDbEvalVariant m_TargetValue; void setTargetValue(const OdDbEvalVariant&); }; ODDB_EVAL_DECLARE_MEMBERS(OdDbBlockLookupAction); /** \details Default constructor */ OdDbBlockLookupAction(); /** \details \returns true if and only if the graph node is activatable */ bool isActivatable() const override; /** \details \returns Number of input columns in the lookup table */ OdUInt32 numberOfInputColumns() const; /** \details \returns Number of output (lookup) columns in the lookup table */ OdUInt32 numberOfOutputColumns() const; /** \details \returns Number of columns in the lookup table */ OdUInt32 numberOfColumns() const; /** \details \returns Number of rows in the lookup table */ OdUInt32 numberOfRows() const; /** \details Get lookup table contents */ void getLookupTable(OdStringArray& values, OdArray& colums) const; /** \details Set lookup table contents, disconnect from the previous paarmeters and connect to the new parameters. */ OdResult setLookupTable(const OdStringArray& values, const OdArray& columns); /** \details Check if there is a duplicated value in the given output (lookup) column. \param columnIndex [in] column to check \param duplicate [out] If the duplicated value is found here will be its (row,column) */ bool duplicateCellsInLookupColumn(unsigned int columnIndex, std::pair* duplicate = nullptr); /** \details Check if there is a duplicated value in the given output (lookup) column. \param values [in] table values \param columns [in] column description array \param columnIndex [in] column to check \param duplicate [out] If the duplicated value is found here will be its (row,column) */ static bool duplicateCellsInLookupColumn(const OdStringArray& values, const OdArray& columns, unsigned int columnIndex, std::pair* duplicate = nullptr); /** \details Check if there is a duplicated row in the table (only input columns are checked). \param duplicate [out] If the duplicated rows are found here will be (row1,row2) */ bool duplicateRowsOverInputColumns(std::pair* duplicate = nullptr); /** \details Check if there is a duplicated row in the table (only input columns are checked). \param values [in] table values \param columns [in] column description array \param duplicate [out] If the duplicated rows are found here will be (row1,row2) */ static bool duplicateRowsOverInputColumns(const OdStringArray& values, const OdArray& columns, std::pair* duplicate = nullptr); /** \details Check if there is a non-singleton range in the table (only input columns are checked). (E.g. "[10, 20)" or a combination of intervals) \param values [in] table values \param columns [in] column description array \param duplicate [out] If the non-singleton range is found here will be (row,column) */ static bool nonSingletonRangeInInputColumns(const OdStringArray& values, const OdArray& columns, std::pair* = nullptr); /** \details Check if there is a non-singleton range in the table (only input columns are checked). (E.g. "[10, 20)" or a combination of intervals) \param duplicate [out] If the non-singleton range is found here will be (row,column) */ bool nonSingletonRangeInInputColumns(std::pair* result = nullptr); /** \details Check if there is an empty string in the input values \param values [in] table values \param columns [in] column description array \param duplicate [out] If an empty string is found here will be (row,column) */ static bool nullsInInputColumns(const OdStringArray& values, const OdArray& columns, std::pair* result = nullptr); /** \details Check if there is an empty string in the input values \param duplicate [out] If an empty string is found here will be (row,column) */ bool nullsInInputColumns(std::pair* result = nullptr); }; typedef OdSmartPtrOdDbBlockLookupActionPtr;