cgma
CubitAttribManager.hpp
Go to the documentation of this file.
00001 #ifndef __CUBITATTRIBMANAGER_HPP__
00002 #define __CUBITATTRIBMANAGER_HPP__
00003 
00004 class RefEntity;
00005 class CubitAttrib;
00006 class CubitAttribUser;
00007 class CubitSimpleAttrib;
00008 
00009 #include "CubitDefines.h"
00010 #include "DLIList.hpp"
00011 #include "CubitString.hpp"
00012 #include "CGMGeomConfigure.h"
00013 
00014 #if defined(_MSC_VER)
00015 #pragma warning(push)
00016 #pragma warning(disable : 4251)  // hide warnings about template dll exports
00017 #endif
00018 
00019 #include <map>
00020 
00021 typedef CubitAttrib* (*CACreateFunction)(RefEntity*, const CubitSimpleAttrib&);
00022 
00023 class CUBIT_GEOM_EXPORT CubitAttribManager
00024 {
00025 public:
00026   CubitAttribManager();
00027   virtual ~CubitAttribManager();
00028 
00029   // stores factory function and settings for an attribute
00030   // returns a key that can be used to refer to the attribute type to avoid search by name
00031   CubitStatus register_attrib_type( const int att_type,
00032                                      const char* att_type_name,
00033                                      const char* att_internal_name,
00034                                      CACreateFunction p_create_function,
00035                                      CubitBoolean auto_actuate_flag,
00036                                      CubitBoolean auto_update_flag,
00037                                      CubitBoolean auto_write_flag,
00038                                      CubitBoolean auto_read_flag,
00039                                      CubitBoolean actuate_in_constructor,
00040                                      CubitBoolean actuate_after_geom_changes);
00041 // actuateInConstructor flag: if this flag is set to true,
00042 // this attribute will be actuated in a constructor, otherwise
00043 // it will be actuated after a geometry operation or geometry
00044 // import; usually, attributes which need full topological information
00045 // must be actuated after the geometry operation is finished
00046 //
00047 // actuateAfterGeomChanges flag: if this flag is set to true,
00048 // this attribute will be actuated only after all changes to geometry
00049 // have been done.  Implies that if an attribute changes geometry,
00050 // or if it doesn't matter, this flag should be false (the default value); 
00051 // if it requires the geometry to be in its final state, this flag 
00052 // should be true
00053 
00054   void get_registered_types(DLIList<int> &types);
00055 
00056   CubitAttrib *create_cubit_attrib(const int attrib_type,
00057                                    RefEntity *attrib_user,
00058                                    const CubitSimpleAttrib& p_csa);
00059 
00060   const char * att_internal_name(int attrib_type);
00061 
00062   CubitBoolean auto_actuate_flag(int attrib_type);
00063   CubitStatus set_auto_actuate_flag(int attrib_type, CubitBoolean value);
00064   void set_all_auto_actuate_flags(CubitBoolean value);
00065 
00066   CubitBoolean auto_update_flag(int attrib_type);
00067   CubitStatus set_auto_update_flag(int attrib_type, CubitBoolean value);
00068   void set_all_auto_update_flags(CubitBoolean value);
00069 
00070   CubitBoolean auto_write_flag(int attrib_type);
00071   CubitStatus set_auto_write_flag(int attrib_type, CubitBoolean value);
00072   void set_all_auto_write_flags(CubitBoolean value);
00073 
00074   CubitBoolean auto_read_flag(int attrib_type);
00075   CubitStatus set_auto_read_flag(int attrib_type, CubitBoolean value);
00076   void set_all_auto_read_flags(CubitBoolean value);
00077 
00078   CubitBoolean actuate_in_constructor(int attrib_type);
00079   CubitBoolean actuate_after_geom_changes(int attrib_type);
00080 
00081   CubitStatus auto_update_attribs(RefEntity *cau);
00082 
00083 //  CubitStatus actuate_list(DLIList<CubitAttribUser*> entity_list);
00084 
00085   int attrib_type(const CubitSimpleAttrib &csa_ptr);
00086   int attrib_type(const char* name);
00087   int attrib_type_from_internal_name(const char* name);
00088 
00089 //  void clear_attrib_importeds() ;
00090 //  void report_attrib_importeds();
00091 
00092   int auto_flag();
00093   void auto_flag(int flag);
00094 
00095   bool silent_flag() {return silentFlag;}
00096   void silent_flag(const bool flag) {silentFlag = flag;}
00097 
00098   const char * att_name(int attrib_type);
00099 
00100 private:
00101 /*
00102   class CARegisterData
00103   {
00104   public:
00105     CARegisterData(const char *type_name, const char *internal_name,
00106                    CACreateFunction p_func, unsigned int flags)
00107     {
00108       mTypeName = type_name;
00109       mInternalName = internal_name;
00110       mCreateFunction = p_func;
00111       mFlags = flags;
00112     }
00113 
00114     ~CARegisterData();
00115 
00116     CubitString mTypeName;
00117     CubitString mInternalName;
00118     CACreateFunction mCreateFunction;
00119     unsigned int mFlags;
00120   };
00121 
00122   #define CA_AUTOACTUATE             0x01
00123   #define CA_AUTOUPDATE              0x02
00124   #define CA_AUTOWRITE               0x04
00125   #define CA_AUTOREAD                0x08
00126   #define CA_ACTUATEINCONSTRUCTOR    0x10
00127   #define CA_ACTUATEAFTERGEOMCHANGES 0x20
00128 
00129   std::map<int, CARegisterData*> mTypeToCAData;
00130 //struct ltstr
00131 //{
00132 //  bool operator()(const char* s1, const char* s2) const
00133 //  {
00134 //    return strcmp(s1, s2) < 0;
00135 //  }
00136 //};
00137 //  std::map<const char*, int, ltstr> mTypeNameToType;
00138 //  std::map<const char*, int, ltstr> mInternalNameToType;
00139 */
00140 
00141   DLIList<int> mTypes;
00142   DLIList<char*> mTypeNames;
00143   DLIList<char*> mInternalNames;
00144   DLIList<CACreateFunction> mCreatorFunctions;
00145   DLIList<CubitBoolean> mAutoActuateFlags;
00146   DLIList<CubitBoolean> mAutoUpdateFlags;
00147   DLIList<CubitBoolean> mAutoWriteFlags;
00148   DLIList<CubitBoolean> mAutoReadFlags;
00149   DLIList<CubitBoolean> mActuateInConstructor;
00150   DLIList<CubitBoolean> mActuateAfterGeomChanges;
00151 
00152   // TODO - get rid of mAttribImported
00153 //  DLIList<CubitBoolean> mAttribImported;
00154 
00155   bool silentFlag;
00156 
00157 };
00158 
00159 #if defined(_MSC_VER)
00160 #pragma warning(pop)
00161 #endif
00162 
00163 #endif //__CUBITATTRIBMANAGER_HPP__
00164 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines