a GMatrix with relation content set by setRation() function already. but i
want to only change the relation name or certain name of attribute. how to do?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
1- call "GMatrix::relation()" to obtain a smart_ptr (see GHolders.h) that
references the relation.
2- call "smart_ptr::get()" to obtain a pointer to the relation (GRelation*).
3- call "GRelation::type()" to make sure that it is ARFF.
4- cast to GArffRelation.
5- call "setName" or "setAttrValueCount", etc. (Hmm, it looks like I have not
provided a "setAttrName" method. Perhaps that should be added.)
Example:
GRelation* pRel = mymatrix.relation().get();
if(pRel->type() != GRelation::ARFF)
ThrowError("Expected a GArffRelation. Got something else.");
GArffRelation pArffRel = (GArffRelation)pRel;
pArffRel->setName("new_name");
(disclaimer: I did not compile this.)
(It seems that my use of smart pointers is what is causing the confusion. It
might help to examine the "smart_ptr" class in GHolders.h, or read about smart
pointers.)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
a GMatrix with relation content set by setRation() function already. but i
want to only change the relation name or certain name of attribute. how to do?
1- call "GMatrix::relation()" to obtain a smart_ptr (see GHolders.h) that
references the relation.
2- call "smart_ptr::get()" to obtain a pointer to the relation (GRelation*).
3- call "GRelation::type()" to make sure that it is ARFF.
4- cast to GArffRelation.
5- call "setName" or "setAttrValueCount", etc. (Hmm, it looks like I have not
provided a "setAttrName" method. Perhaps that should be added.)
Example:
GRelation* pRel = mymatrix.relation().get();
if(pRel->type() != GRelation::ARFF)
ThrowError("Expected a GArffRelation. Got something else.");
GArffRelation pArffRel = (GArffRelation)pRel;
pArffRel->setName("new_name");
(disclaimer: I did not compile this.)
(It seems that my use of smart pointers is what is causing the confusion. It
might help to examine the "smart_ptr" class in GHolders.h, or read about smart
pointers.)