Skip to content

Commit

Permalink
#199: nrofRows -> Categorical and cat_range function added
Browse files Browse the repository at this point in the history
  • Loading branch information
MaartenHilferink committed Apr 5, 2023
1 parent 3ec80c5 commit ba26853
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
21 changes: 11 additions & 10 deletions clc/dll/src2/OperUnit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,18 +561,14 @@ class UnitRangeOperator : public TernaryOperator
typedef DataArray<T> Arg3Type; // UpperBound

static_assert(has_var_range_field_v<T>);
bool m_IsCatRangeFunc;

public:
UnitRangeOperator(AbstrOperGroup* gr)
: TernaryOperator(gr,
ResultType::GetStaticClass(),
Arg1Type::GetStaticClass(),
Arg2Type::GetStaticClass(),
Arg3Type::GetStaticClass()
)
UnitRangeOperator(AbstrOperGroup* gr, bool isCatRangeFunc)
: TernaryOperator(gr, ResultType::GetStaticClass(), Arg1Type::GetStaticClass(), Arg2Type::GetStaticClass(), Arg3Type::GetStaticClass())
, m_IsCatRangeFunc(isCatRangeFunc)
{}


// Override Operator
bool CreateResult(TreeItemDualRef& resultHolder, const ArgSeqType& args, bool mustCalc) const override
{
Expand All @@ -591,6 +587,8 @@ class UnitRangeOperator : public TernaryOperator
dms_assert(result);
resultHolder = result;
result->DuplFrom(arg1);
if (m_IsCatRangeFunc)
result->SetTSF(TSF_Categorical);
}

if (mustCalc)
Expand Down Expand Up @@ -1102,7 +1100,8 @@ namespace

CommonOperGroup
cog_Range(token::range),
cog_LowerBound("LowerBound"),
cog_CatRange("cat_range"),
cog_LowerBound("LowerBound"),
cog_UpperBound("UpperBound"),
cog_BoundRange("BoundRange"),
cog_BoundCenter("BoundCenter");
Expand All @@ -1111,7 +1110,7 @@ namespace
struct UnitRangeOperators
{
UnitRangeOperators()
: ur(&cog_Range)
: ur(&cog_Range, false)
, lb(&cog_LowerBound)
, ub(&cog_UpperBound)
, rb(&cog_BoundRange)
Expand Down Expand Up @@ -1156,6 +1155,8 @@ namespace
tl_oper::inst_tuple<typelists::ranged_unit_objects, UnitRangeOperators<_> > unitRangeOpers;
tl_oper::inst_tuple<typelists::bints, UnitFixedRangeOperators<_> > unitFixedRangeOpers;

tl_oper::inst_tuple<typelists::domain_objects, UnitRangeOperator<_>, AbstrOperGroup*, bool> unitCatRangeOpers(&cog_CatRange, true);

CommonOperGroup cog_combine("combine", oper_policy::allow_extra_args);
CommonOperGroup cog_combine08("combine_uint8", oper_policy::allow_extra_args);
CommonOperGroup cog_combine16("combine_uint16", oper_policy::allow_extra_args);
Expand Down
21 changes: 15 additions & 6 deletions stx/dll/src/ConfigProd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,9 @@ void ConfigProd::SetVC (ValueComposition vc)
// *****************************************************************************

// REMOVE COMMENT: Integreer met DoNrOfRowsProp()
void ConfigProd::DoUnitRangeProp()
void ConfigProd::DoUnitRangeProp(bool isCategorical)
{
dms_assert(m_pCurrent);
assert(m_pCurrent);
AbstrUnit* unit = AsCheckedUnit(m_pCurrent.get_ptr());
dms_assert(unit);
const ValueClass* vc = unit->GetValueType();
Expand Down Expand Up @@ -588,10 +588,19 @@ void ConfigProd::DoItemName()

void ConfigProd::DoNrOfRowsProp()
{
m_FloatInterval.first = 0;
m_FloatInterval.second = m_FloatVal;
m_eAssignmentDomainType = m_eValueType;
DoUnitRangeProp();
assert(m_eValueType == VT_UInt32);
assert(m_pCurrent);

AbstrUnit* unit = AsCheckedUnit(m_pCurrent.get_ptr());
assert(unit);
const ValueClass* vc = unit->GetValueType();
assert(vc);

if (!vc->IsNumeric())
throwSemanticError(mgFormat2string("DoUnitRangeProp: the provided range is incompatible with the ValueType %s of this unit", vc->GetName()).c_str());

unit->SetTSF(USF_HasConfigRange | TSF_Categorical);
unit->SetRangeAsFloat64(0, m_IntValAsUInt32);
}

void ConfigProd::throwSemanticError(CharPtr msg)
Expand Down
2 changes: 1 addition & 1 deletion stx/dll/src/ConfigProd.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ struct ConfigProd : AbstrDataBlockProd
void DoStorageProp();
void DoFileType();
void DoUsingProp();
void DoUnitRangeProp();
void DoUnitRangeProp(bool isCategorical);
void DoNrOfRowsProp();

void DoArrayAssignment () override;
Expand Down

0 comments on commit ba26853

Please sign in to comment.