cgma
|
#include <CATag.hpp>
Public Member Functions | |
virtual | ~CATag () |
virtual const type_info & | entity_type_info () const |
CubitStatus | actuate () |
CubitStatus | update () |
CubitStatus | reset () |
CubitSimpleAttrib | split_owner () |
void | merge_owner (CubitAttrib *deletable_attrib) |
CubitSimpleAttrib | cubit_simple_attrib () |
int | int_attrib_type () |
void | add_csa_data (CubitSimpleAttrib *csa_ptr) |
void | print () |
iBase_ErrorType | get_tag_data (long tag_num, void *tag_data) |
iBase_ErrorType | set_tag_data (long tag_num, const void *tag_data, const bool can_shallow_copy=false) |
void | remove_tag (long tag_num) |
Private Member Functions | |
CATag (CGMTagManager *manager, RefEntity *owner) | |
CATag (CGMTagManager *manager, RefEntity *owner, CubitSimpleAttrib *csa_ptr) | |
Private Attributes | |
std::map< int, void * > | tagData |
CGMTagManager * | myManager |
Friends | |
class | CGMTagManager |
CATag::CATag | ( | CGMTagManager * | manager, |
RefEntity * | owner | ||
) | [private] |
Definition at line 792 of file CATag.cpp.
: CubitAttrib(entity), myManager(manager) { }
CATag::CATag | ( | CGMTagManager * | manager, |
RefEntity * | owner, | ||
CubitSimpleAttrib * | csa_ptr | ||
) | [private] |
Definition at line 797 of file CATag.cpp.
: CubitAttrib(owner), myManager(manager) { if (NULL != csa_ptr) add_csa_data(csa_ptr); }
CATag::~CATag | ( | ) | [virtual] |
CubitStatus CATag::actuate | ( | ) | [inline, virtual] |
void CATag::add_csa_data | ( | CubitSimpleAttrib * | csa_ptr | ) |
Definition at line 857 of file CATag.cpp.
{ // make sure it's a CATag static CubitString my_type("CA_TAG"); if (csa_ptr->character_type() != my_type) return; int num_attribs = csa_ptr->int_data_list()[0]; int *tmp_data; for (int i = 0; i < num_attribs; i++) { // map the attrib name to a tag std::map<std::string,long>::iterator pos = myManager->tagNameMap.find(std::string(csa_ptr->string_data_list()[i].c_str())); long thandle = 0; if (pos == myManager->tagNameMap.end()) { // tag doesn't exist - create one myManager->createTag(csa_ptr->string_data_list()[i].c_str(), csa_ptr->int_data_list()[i], iBase_BYTES, NULL, &thandle); } else thandle = (*pos).second; long tag_handle = thandle; // copy the ints to a temporary space we can get a ptr to... int int_length = csa_ptr->int_data_list()[i]; if (int_length % 4 != 0) int_length++; tmp_data = (int*) malloc(int_length*sizeof(int)); for (int j = 0; j < int_length; j++) tmp_data[j] = csa_ptr->int_data_list()[j]; // now actually set the data this->set_tag_data(tag_handle, tmp_data, true); } }
CubitSimpleAttrib CATag::cubit_simple_attrib | ( | ) | [virtual] |
Implements CubitAttrib.
Definition at line 814 of file CATag.cpp.
{ //if (tagData.size() == 0) return NULL; std::vector<int, std::allocator<int> >int_data; std::vector<CubitString> str_data; std::vector<double> dbl_data; str_data.push_back(myManager->CATag_NAME_INTERNAL); // int data first gets the # tags on this entity int_data.push_back(tagData.size()); // for each tag: for (std::map<int, void*>::iterator mit = tagData.begin(); mit != tagData.end(); mit++) { long tag_handle = (*mit).first; CGMTagManager::TagInfo *tinfo = (tag_handle > 0 ? &(myManager->tagInfo[tag_handle]) : &(myManager->presetTagInfo[-tag_handle])); // store the name str_data.push_back(tinfo->tagName.c_str()); // store the length in bytes int_data.push_back(tinfo->tagLength); // now the data // store the raw memory interpreted as an array of ints, padded to a full int int tag_ints = tinfo->tagLength/4; if (tinfo->tagLength % 4 != 0) tag_ints++; int *tag_data = reinterpret_cast<int*>((*mit).second); for (int i = 0; i < tag_ints; i++) int_data.push_back(tag_data[i]); } // store the data on the csa CubitSimpleAttrib csa(&str_data, &dbl_data, &int_data); return csa; }
virtual const type_info& CATag::entity_type_info | ( | ) | const [inline, virtual] |
iBase_ErrorType CATag::get_tag_data | ( | long | tag_num, |
void * | tag_data | ||
) |
Definition at line 911 of file CATag.cpp.
{ assert(NULL != tag_data); CGMTagManager::TagInfo *tinfo = (tag_handle > 0 ? &(myManager->tagInfo[tag_handle]) : &(myManager->presetTagInfo[-tag_handle])); // check if this attribute has this tag std::map<int, void*>::iterator tdpos = tagData.find(tag_handle); if (tdpos == tagData.end()) { if (NULL != tinfo->defaultValue) memcpy(tag_data, tinfo->defaultValue, tinfo->tagLength); else { CGM_iGeom_setLastError( iBase_TAG_NOT_FOUND ); return iBase_TAG_NOT_FOUND; } } else memcpy(tag_data, (*tdpos).second, tinfo->tagLength); RETURN(iBase_SUCCESS); }
int CATag::int_attrib_type | ( | ) | [inline, virtual] |
Implements CubitAttrib.
Definition at line 197 of file CATag.hpp.
{return myManager->CATag_att_type;}
void CATag::merge_owner | ( | CubitAttrib * | deletable_attrib | ) | [inline, virtual] |
void CATag::print | ( | ) | [virtual] |
Reimplemented from CubitAttrib.
Definition at line 899 of file CATag.cpp.
{ std::cout << "This entity has " << tagData.size() << " tags. Types are: " << std::endl; for (std::map<int,void*>::iterator mit = tagData.begin(); mit != tagData.end(); mit++) { if ((*mit).first > 0) std::cout << myManager->tagInfo[(*mit).first].tagName << std::endl; else std::cout << myManager->presetTagInfo[-(*mit).first].tagName << std::endl; } }
void CATag::remove_tag | ( | long | tag_num | ) |
CubitStatus CATag::reset | ( | ) | [virtual] |
Implements CubitAttrib.
Definition at line 803 of file CATag.cpp.
{ for (std::map<int, void*>::iterator mit = tagData.begin(); mit != tagData.end(); mit++) if (NULL != (*mit).second) free ((*mit).second); tagData.clear(); return CUBIT_SUCCESS; }
iBase_ErrorType CATag::set_tag_data | ( | long | tag_num, |
const void * | tag_data, | ||
const bool | can_shallow_copy = false |
||
) |
Definition at line 937 of file CATag.cpp.
{ CGMTagManager::TagInfo *tinfo = (tag_handle > 0 ? &(myManager->tagInfo[tag_handle]) : &(myManager->presetTagInfo[-tag_handle])); // check if this attribute has this tag std::map<int, void*>::iterator tdpos = tagData.find(tag_handle); if (tdpos == tagData.end()) tdpos = tagData.insert(tagData.end(), std::pair<int,void*>(tag_handle, reinterpret_cast<void*>(0))); // XXX(msvc2010): complains about NULL cast to void*? if (!can_shallow_copy) { // need to copy the data; might need to allocate first if ((*tdpos).second == NULL) (*tdpos).second = malloc(tinfo->tagLength); memcpy((*tdpos).second, tag_data, tinfo->tagLength); } else { // should shallow copy; might have to delete what's there already if ((*tdpos).second != NULL) free((*tdpos).second); // if shallow copying, caller is saying we can copy, so cast away const (*tdpos).second = const_cast<void*>(tag_data); } RETURN(iBase_SUCCESS); }
CubitSimpleAttrib CATag::split_owner | ( | ) | [inline, virtual] |
Reimplemented from CubitAttrib.
Definition at line 191 of file CATag.hpp.
{ CubitSimpleAttrib sa; return sa; }
CubitStatus CATag::update | ( | ) | [virtual] |
Implements CubitAttrib.
Definition at line 974 of file CATag.cpp.
{ if (tagData.empty()) this->delete_attrib(true); return CUBIT_SUCCESS; }
friend class CGMTagManager [friend] |
CGMTagManager* CATag::myManager [private] |
std::map<int, void*> CATag::tagData [private] |