![]() |
【转帖】rtti And Entities
rtti and entities
rtti and entities hi there, i'd like to use rtti when iterating through an oddbblocktablerecord to select for certain entities like circles,text or lines etc. i could use the odrxclass and retreive the type-string but i'd like to use the typeid. is that possible with opendwg c++ ? or should use odrxclass::name() to compare with ? thanks in advance. sander koning i'm not sure about rtti - you can use it over pointers (but not smart) to entities and objects: like dynamic_cast<oddbline&>(*pent) (which by the way will throw an exception if pent is not a line) or dynamic_cast<oddbcircle*>(pent.get()), whcih will return 0 if pent is not a circle. but it is not recommended to use the name() property of the type_info class, because it may differ between the different c++ compilers. moreover, it can differ between 2 versions of a same compiler. i would recommend to use pent->isa()->name() to get the real string of the pointed type. you can even remove the "acdb" preffix and use a "normalized" form of the type, for example in interface components. another check can be ( pent->iskindof(oddbcircle::desc()) ) which is similar to ( dynamic_cast<oddbcircle*>(pent.get()) != 0 ). hope this helps. best regards chudomir pent->isa()->name() is most reliable thanks for your reply chudo, i've tested both statements and pent->isa()->name() fff"> is the most reliable. pent->iskindof(oddbcircle::desc()) fff"> didn't only gave exactly the ones i wanted, but also some extra entity types wich seemed to be related somehow in it's ancestor's tree. so for now i would only recommend pent->isa()->name() fff"> to check the entity-type. with regards, sander koning |
所有的时间均为北京时间。 现在的时间是 05:09 AM. |