OCAF store two integers in one label

karim

CAD community veteran
It seems one can store one integer and one real in a label. But what if one wants to have two integers stored in one label ? does it make sense to store two values of the same type in one label ?

TDataStd_Integer::Set(child1, 200);
TDataStd_Integer::Set(child1, 300);
TDataStd_Real::Set(child1, 23.5);

std::cout <<" added childes " << std::endl;

Handle(TDataStd_Integer) i;
if( child1.FindAttribute(TDataStd_Integer::GetID(), i))
{
std::cout << i->Get() << std::endl;
}
// prints 300 as expected.

Handle(TDataStd_Real) r;
if( child1.FindAttribute(TDataStd_Real::GetID(), r))
{
std::cout << r->Get() << std::endl;
} //prints 23.5 as expected.
else {
std::cout << "could not find real " << std::endl;
}

How TDataStd_Real::GetID() knows about the ID of the real stored in the child ?
 

Quaoar

Administrator
Staff member
@karim That's the design choice of OCAF. You can have only one attribute of a certain type in one label. And the type of an attribute is determined by its static GUID. That's generally not a problem as you can still allocate TDataStd_RealArray (or an array of any other integral type) to hold multiple scalar values.
 
Top