cgma
|
00001 //------------------------------------------------------------------------- 00002 // Filename : CAMergeStatus.cpp 00003 // 00004 // Purpose : Save RefEntity::autoMergeStatus 00005 // 00006 // Special Notes : 00007 // 00008 // Creator : Jason Kraftcheck 00009 // 00010 // Creation Date : 06/06/02 00011 //------------------------------------------------------------------------- 00012 00013 #include "RefEntity.hpp" 00014 #include "CAMergeStatus.hpp" 00015 #include "CADefines.hpp" 00016 00017 CubitAttrib* CAMergeStatus_creator(RefEntity* entity, const CubitSimpleAttrib &p_csa) 00018 { 00019 return new CAMergeStatus(entity, p_csa); 00020 } 00021 00022 CAMergeStatus::CAMergeStatus( RefEntity* owner, const CubitSimpleAttrib& csa ) 00023 : CubitAttrib( owner ) 00024 { 00025 status = AUTO_MERGE_AUTO; 00026 if(!csa.isEmpty()) 00027 { 00028 assert( csa.int_data_list().size() == 1 ); 00029 int i = csa.int_data_list()[0]; 00030 assert( i == 0 || i == 1 || i == 2 ); 00031 status = (AutoMergeStatus)i; 00032 } 00033 } 00034 00035 CAMergeStatus::~CAMergeStatus() 00036 { } 00037 00038 CubitStatus CAMergeStatus::actuate() 00039 { 00040 if( hasActuated ) 00041 return CUBIT_SUCCESS; 00042 00043 if( !attribOwnerEntity ) 00044 return CUBIT_FAILURE; 00045 00046 DLIList<CubitAttrib*> att_list; 00047 attribOwnerEntity->find_cubit_attrib_type(CA_MERGE_PARTNER, att_list); 00048 if( att_list.size() ) 00049 return CUBIT_FAILURE; 00050 00051 assert( status == AUTO_MERGE_ON || status == AUTO_MERGE_OFF ); 00052 attribOwnerEntity->is_mergeable(status); 00053 00054 deleteAttrib = CUBIT_FALSE; 00055 hasActuated = CUBIT_TRUE; 00056 00057 return CUBIT_SUCCESS; 00058 } 00059 00060 CubitStatus CAMergeStatus::update() 00061 { 00062 if( hasUpdated ) 00063 return CUBIT_SUCCESS; 00064 00065 if( !attribOwnerEntity ) 00066 return CUBIT_FAILURE; 00067 00068 status = attribOwnerEntity->merge_status(); 00069 if( status == AUTO_MERGE_AUTO ) 00070 delete_attrib(CUBIT_TRUE); 00071 else 00072 hasUpdated = CUBIT_TRUE; 00073 00074 return CUBIT_SUCCESS; 00075 } 00076 00077 CubitStatus CAMergeStatus::reset() 00078 { 00079 return CUBIT_SUCCESS; 00080 } 00081 00082 CubitSimpleAttrib CAMergeStatus::cubit_simple_attrib() 00083 { 00084 if( deleteAttrib ) 00085 return CubitSimpleAttrib(); 00086 00087 assert( status != AUTO_MERGE_AUTO ); 00088 00089 std::vector<CubitString> string_list; 00090 string_list.push_back(att_internal_name()); 00091 00092 int int_data = (int)status; 00093 std::vector<int> int_list; 00094 int_list.push_back( int_data ); 00095 00096 return CubitSimpleAttrib( &string_list, 0, &int_list ); 00097 } 00098 00099 int CAMergeStatus::int_attrib_type() 00100 { 00101 return CA_MERGE_STATUS; 00102 } 00103