cgma
|
00001 //- Filename: CubitSimpleAttrib.cc 00002 //- Description: Implementation of class CubitSimpleAttrib 00003 //- Owner: Greg Nielson 00004 //- Checked by: 00005 //- Version: 00006 00007 #include <string.h> 00008 #include "SettingHandler.hpp" 00009 00010 #include "CubitSimpleAttrib.hpp" 00011 #include "CubitString.hpp" 00012 #include "CubitMessage.hpp" 00013 #include "RefEntity.hpp" 00014 #include "RefEntityFactory.hpp" 00015 #include "CubitFileIOWrapper.hpp" 00016 00017 CubitBoolean CubitSimpleAttrib::pushAttribs = CUBIT_FALSE; 00018 00019 //SettingHolder SettingHandler::settingObject43 = SettingHolder("Push_Attribs", CubitSimpleAttrib::set_push_attribs, CubitSimpleAttrib::get_push_attribs, CUBIT_FALSE); 00020 00021 CubitSimpleAttrib::CubitSimpleAttrib() 00022 { 00023 } 00024 00025 CubitSimpleAttrib::~CubitSimpleAttrib() 00026 { 00027 } 00028 00029 CubitSimpleAttrib::CubitSimpleAttrib(const CubitString new_character_type, 00030 const CubitString new_string_data, 00031 const CubitString new_more_string_data, 00032 const int* new_integer_data, 00033 const double* new_double_data) 00034 { 00035 assert(new_character_type.length() > 0); 00036 00037 stringDataList.push_back(new_character_type); 00038 00039 if (new_string_data.length()) { 00040 stringDataList.push_back(new_string_data); 00041 } 00042 00043 if (new_more_string_data.length()) { 00044 stringDataList.push_back(new_more_string_data); 00045 } 00046 00047 if(new_double_data) 00048 doubleDataList.push_back( *new_double_data ); 00049 if(new_integer_data) 00050 intDataList.push_back( *new_integer_data ); 00051 00052 return; 00053 } 00054 00055 bool CubitSimpleAttrib::isEmpty() const 00056 { 00057 return stringDataList.empty() && 00058 doubleDataList.empty() && 00059 intDataList.empty(); 00060 } 00061 00062 CubitSimpleAttrib::CubitSimpleAttrib(const CubitSimpleAttrib& csa_ptr) 00063 { 00064 this->stringDataList = csa_ptr.stringDataList; 00065 this->doubleDataList = csa_ptr.doubleDataList; 00066 this->intDataList = csa_ptr.intDataList; 00067 } 00068 00069 CubitSimpleAttrib::CubitSimpleAttrib(const std::vector<CubitString> *string_list, 00070 const std::vector<double> *double_list, 00071 const std::vector<int> *int_list) 00072 { 00073 if(string_list) 00074 this->stringDataList = *string_list; 00075 if(double_list) 00076 this->doubleDataList = *double_list; 00077 if(int_list) 00078 this->intDataList = *int_list; 00079 } 00080 00081 00082 CubitSimpleAttrib &CubitSimpleAttrib::operator=(const CubitSimpleAttrib &other) 00083 { 00084 this->stringDataList = other.stringDataList; 00085 this->intDataList = other.intDataList; 00086 this->doubleDataList = other.doubleDataList; 00087 return *this; 00088 } 00089 00090 CubitString CubitSimpleAttrib::character_type() const //- returns the type of attribute 00091 { 00092 if(stringDataList.size() >= 1 ) 00093 { 00094 return stringDataList[0]; 00095 } 00096 return CubitString(); 00097 } 00098 00099 void CubitSimpleAttrib::string_data_list( const std::vector<CubitString>& new_list) 00100 { 00101 this->stringDataList = new_list; 00102 } 00103 00104 void CubitSimpleAttrib::double_data_list(const std::vector<double>& new_list) 00105 { 00106 doubleDataList = new_list; 00107 } 00108 00109 void CubitSimpleAttrib::int_data_list(const std::vector<int>& new_list) 00110 { 00111 intDataList = new_list; 00112 } 00113 00114 bool CubitSimpleAttrib::operator==(const CubitSimpleAttrib& other) const 00115 { 00116 return this->stringDataList == other.stringDataList && 00117 this->doubleDataList == other.doubleDataList && 00118 this->intDataList == other.intDataList; 00119 } 00120 00121 00122 //Initialize all settings in this class 00123 void CubitSimpleAttrib::initialize_settings() 00124 { 00125 00126 SettingHandler::instance()->add_setting("Push Attribs", 00127 CubitSimpleAttrib::set_push_attribs, 00128 CubitSimpleAttrib::get_push_attribs); 00129 } 00130 00131 void CubitSimpleAttrib::print() const 00132 { 00133 PRINT_INFO("CSA: type = %s\n", stringDataList[0].c_str()); 00134 00135 PRINT_INFO("String data: "); 00136 for ( size_t i=1; i<stringDataList.size(); i++) 00137 PRINT_INFO("%s;", stringDataList[i].c_str()); 00138 if (stringDataList.size() == 0) 00139 PRINT_INFO("(none)"); 00140 PRINT_INFO("\n"); 00141 00142 PRINT_INFO("Int data: "); 00143 for (size_t i=0; i<intDataList.size(); i++) 00144 PRINT_INFO("%d;", intDataList[i]); 00145 if (intDataList.size() == 0) 00146 PRINT_INFO("(none)"); 00147 PRINT_INFO("\n"); 00148 00149 PRINT_INFO("Double data: "); 00150 for (size_t i=0; i<doubleDataList.size(); i++) 00151 PRINT_INFO("%f;", doubleDataList[i]); 00152 if (doubleDataList.size() == 0) 00153 PRINT_INFO("(none)"); 00154 PRINT_INFO("\n"); 00155 } 00156