cgma
|
00001 00024 #ifndef CA_TAG_HPP 00025 #define CA_TAG_HPP 00026 00027 #include <typeinfo> 00028 #if !defined(_WIN32) 00029 using std::type_info; 00030 #endif 00031 00032 #include "iGeom.h" 00033 #include "CubitAttrib.hpp" 00034 #include "DLIList.hpp" 00035 #include "CubitDefines.h" 00036 00037 #include <string> 00038 #include <map> 00039 #include <vector> 00040 00041 #ifdef ITAPS_SHIM 00042 typedef struct iGeom_Instance_Private *iGeom_Instance; 00043 # include "iGeom_binding.h" 00044 #endif 00045 00046 #define ARRAY_IN_DECL(a, b) \ 00047 a const* b, const int b ## _size 00048 00049 #define ARRAY_INOUT_DECL(a, b) \ 00050 a **b, int *b ## _allocated, int *b ## _size 00051 00052 class RefEntity; 00053 class RefGroup; 00054 class CATag; 00055 00056 class CGMTagManager 00057 { 00058 public: 00059 #ifdef ITAPS_SHIM 00060 iGeom_vtable *vtable; 00061 #endif 00062 00063 friend class CATag; 00064 00065 ~CGMTagManager(); 00066 00067 struct TagInfo 00068 { 00069 int tagLength; 00070 std::string tagName; 00071 int tagType; 00072 char *defaultValue; 00073 bool isActive; 00074 }; 00075 00076 static CubitAttrib* CATag_creator(RefEntity* entity, const CubitSimpleAttrib &p_csa); 00077 00078 iBase_ErrorType createTag (/*in*/ const char *tag_name, 00079 /*in*/ const int tag_size, 00080 /*in*/ const int tag_type, 00081 /*in*/ char* default_value, 00082 /*out*/ long *tag_handle); 00083 00084 iBase_ErrorType destroyTag (/*in*/ const long tag_handle, 00085 /*in*/ const bool forced); 00086 00087 const char *getTagName (/*in*/ const long tag_handle); 00088 00089 int getTagSize (/*in*/ const long tag_handle); 00090 00091 long getTagHandle (/*in*/ const char *tag_name); 00092 00093 int getTagType (/*in*/ const long tag_handle); 00094 00095 iBase_ErrorType getArrData ( ARRAY_IN_DECL(RefEntity*, entity_handles), 00096 /*in*/ const long tag_handle, 00097 /*inout*/ ARRAY_INOUT_DECL(char, tag_value)); 00098 00099 iBase_ErrorType setArrData (/*in*/ ARRAY_IN_DECL(RefEntity*, entity_handles), 00100 /*in*/ const long tag_handle, 00101 /*in*/ const char *tag_values, 00102 const int tag_values_size); 00103 00104 iBase_ErrorType rmvArrTag (/*in*/ ARRAY_IN_DECL(RefEntity*, entity_handles), 00105 /*in*/ const long tag_handle); 00106 00107 iBase_ErrorType getAllTags (/*in*/ const RefEntity* entity_handle, 00108 /*inout*/ ARRAY_INOUT_DECL(long, tag_handles)); 00109 00110 std::vector<RefGroup*> *pc_list(RefEntity *gentity, int list_no, 00111 const bool create_if_missing); 00112 00113 void pc_list(RefEntity *gentity, std::vector<RefGroup*> *&parents, 00114 std::vector<RefGroup*> *&children, 00115 const bool create_if_missing); 00116 00117 void get_pc_groups(RefGroup *this_grp, const int p_or_c, const int num_hops, 00118 std::vector<RefGroup *> &group_ptrs); 00119 00120 iBase_ErrorType create_csa_tag(const char *tag_name, long *tag_handle); 00121 00122 iBase_ErrorType set_csa_tag(RefEntity *this_ent, 00123 long tag_handle, 00124 CubitSimpleAttrib *csa_ptr); 00125 00126 static inline CGMTagManager& instance() 00127 { 00128 static CGMTagManager static_instance; 00129 return static_instance; 00130 } 00131 00132 private: 00133 CGMTagManager(); 00134 00135 int CATag_att_type; 00136 long pcTag; 00137 std::vector<TagInfo> tagInfo; 00138 static TagInfo* const presetTagInfo; 00139 static const int numPresetTag; 00140 std::map<std::string, long> tagNameMap; 00141 static const char *CATag_NAME; 00142 static const char *CATag_NAME_INTERNAL; 00143 RefGroup *interfaceGroup; 00144 00145 bool getPresetTagData(const RefEntity *entity, const long tag_num, 00146 char *tag_value, int &tag_size); 00147 00148 iBase_ErrorType setPresetTagData(RefEntity *entity, const long tag_num, 00149 const char *tag_value, const int tag_size); 00150 00151 CATag *get_catag(RefEntity *ent, 00152 const bool create_if_missing = false); 00153 00154 long pc_tag(const bool create_if_missing = false); 00155 00156 RefGroup *interface_group(const bool create_if_missing = true); 00157 00158 CubitSimpleAttrib* get_simple_attrib( RefEntity* entity, const char* name ); 00159 }; 00160 00161 class CATag: public CubitAttrib 00162 { 00163 private: 00164 friend class CGMTagManager; 00165 00166 std::map<int, void*> tagData; 00167 00168 CGMTagManager *myManager; 00169 00170 CATag(CGMTagManager *manager, RefEntity *owner); 00171 00172 CATag(CGMTagManager *manager, RefEntity *owner, CubitSimpleAttrib *csa_ptr); 00173 //- create a CATag from a simple attribute 00174 00175 public: 00176 00177 virtual ~CATag(); 00178 00179 //HEADER- RTTI and safe casting functions. 00180 virtual const type_info& entity_type_info() const 00181 { return typeid(CATag);} 00182 //R- The geometric modeler type 00183 //- This function returns the type of the geometric modeler. 00184 00185 CubitStatus actuate() {return CUBIT_SUCCESS;} 00186 00187 CubitStatus update(); 00188 00189 CubitStatus reset(); 00190 00191 CubitSimpleAttrib split_owner() { CubitSimpleAttrib sa; return sa; } 00192 00193 void merge_owner(CubitAttrib *deletable_attrib) {} 00194 00195 CubitSimpleAttrib cubit_simple_attrib(); 00196 00197 int int_attrib_type() {return myManager->CATag_att_type;} 00198 00199 void add_csa_data(CubitSimpleAttrib *csa_ptr); 00200 00201 void print(); 00202 00203 iBase_ErrorType get_tag_data(long tag_num, void *tag_data); 00204 00205 iBase_ErrorType set_tag_data(long tag_num, const void *tag_data, 00206 const bool can_shallow_copy = false); 00207 00208 void remove_tag(long tag_num); 00209 }; 00210 00211 #endif 00212