Menu

cann`t change the relation content of GMatrix

Help
doityth777
2012-05-01
2012-09-14
  • doityth777

    doityth777 - 2012-05-01

    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?

     
  • Mike Gashler

    Mike Gashler - 2012-05-01

    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.)

     

Anonymous
Anonymous

Add attachments
Cancel





Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.