-
-#include "SALOMEDS_AttributeComment_i.hxx"
-
-#include "SALOMEDS_AttributeTreeNode_i.hxx"
-#include "SALOMEDS_AttributeUserID_i.hxx"
-
-#include "SALOMEDS_AttributePersistentRef_i.hxx"
-#include "SALOMEDS_AttributeIOR_i.hxx"
-#include "SALOMEDS_AttributeExternalFileDef_i.hxx"
-#include "SALOMEDS_AttributeFileType_i.hxx"
-#include "SALOMEDS_AttributeName_i.hxx"
-#include "SALOMEDS_AttributeSequenceOfInteger_i.hxx"
-#include "SALOMEDS_AttributeSequenceOfReal_i.hxx"
-#include "SALOMEDS_AttributeTableOfInteger_i.hxx"
-#include "SALOMEDS_AttributeTableOfReal_i.hxx"
-#include "SALOMEDS_AttributeTableOfString_i.hxx"
-#include "SALOMEDS_AttributeInteger_i.hxx"
-#include "SALOMEDS_AttributeReal_i.hxx"
-#include "SALOMEDS_AttributeDrawable_i.hxx"
-#include "SALOMEDS_AttributeSelectable_i.hxx"
-#include "SALOMEDS_AttributeExpandable_i.hxx"
-#include "SALOMEDS_AttributeOpened_i.hxx"
-#include "SALOMEDS_AttributeTextColor_i.hxx"
-#include "SALOMEDS_AttributeTextHighlightColor_i.hxx"
-#include "SALOMEDS_AttributePixMap_i.hxx"
-#include "SALOMEDS_AttributeTarget_i.hxx"
-#include "SALOMEDS_AttributeLocalID_i.hxx"
-#include "SALOMEDS_AttributeStudyProperties_i.hxx"
-#include "SALOMEDS_AttributePythonObject_i.hxx"
-
-#include "SALOMEDS_AttributeGraphic_i.hxx"
-#include "SALOMEDS_AttributeFlags_i.hxx"
-
-#include "Utils_ExceptHandlers.hxx"
-UNEXPECT_CATCH(GALockProtection, SALOMEDS::GenericAttribute::LockProtection);
-
-#include "utilities.h"
-
-using namespace std;
-using namespace SALOMEDS;
-
-
-inline bool operator<(const Standard_GUID& theLeft, const Standard_GUID& theRight)
-{
- char aLeft[40] = "";
- theLeft.ToCString(aLeft);
-
- char aRight[40] = "";
- theRight.ToCString(aRight);
-
- return strcmp(aLeft,aRight) < 0;
-}
-
-
-namespace SALOMEDS{
-
- const char* Str(const TCollection_ExtendedString& theString)
- {
- return TCollection_AsciiString(theString).ToCString();
- }
-
- typedef std::string TAttributeID;
-
- typedef Standard_GUID (*TGetGUID)();
- typedef bool (*TIsCheckLockedStudy)();
- typedef Handle(TDF_Attribute) (*TNewAttribute)();
- typedef SALOMEDS_GenericAttribute_i* (*TNewInstance)(const Handle(TDF_Attribute)&, SALOMEDS_SObject_i*);
-
- struct TAttrFun{
- TAttrFun(const TGetGUID& theGetGUID,
- const TIsCheckLockedStudy& theIsCheckLockedStudy,
- const TNewAttribute& theNewAttribute,
- const TNewInstance& theNewInstance):
- myGetGUID(theGetGUID),
- myIsCheckLockedStudy(theIsCheckLockedStudy),
- myNewAttribute(theNewAttribute),
- myNewInstance(theNewInstance)
- {
- }
-
- TGetGUID myGetGUID;
- TIsCheckLockedStudy myIsCheckLockedStudy;
- TNewAttribute myNewAttribute;
- TNewInstance myNewInstance;
- };
-
- typedef std::map<TAttributeID,TAttrFun> TAttrID2FunMap;
- static TAttrID2FunMap __AttrID2FunMap__;
-
-
- typedef std::map<Standard_GUID,TAttributeID> TGUID2AttrIDMap;
- static TGUID2AttrIDMap __GUID2AttrIDMap__;
-
- bool Init()
- {
-
-#define ADD_ATTRID2FUNMAP_ITEM(theName) \
- __AttrID2FunMap__.insert( \
- TAttrID2FunMap::value_type(#theName,TAttrFun( \
- &(SALOMEDS_##theName##_i::GetGUID), \
- &(SALOMEDS_##theName##_i::IsCheckLockedStudy), \
- &(SALOMEDS_##theName##_i::NewAttribute), \
- &(SALOMEDS_##theName##_i::NewInstance) \
- )))
-
- ADD_ATTRID2FUNMAP_ITEM(AttributeName);
- ADD_ATTRID2FUNMAP_ITEM(AttributeComment);
- ADD_ATTRID2FUNMAP_ITEM(AttributeIOR);
- ADD_ATTRID2FUNMAP_ITEM(AttributeReal);
- ADD_ATTRID2FUNMAP_ITEM(AttributeInteger);
- ADD_ATTRID2FUNMAP_ITEM(AttributeSequenceOfInteger);
- ADD_ATTRID2FUNMAP_ITEM(AttributeSequenceOfReal);
- ADD_ATTRID2FUNMAP_ITEM(AttributeTableOfInteger);
- ADD_ATTRID2FUNMAP_ITEM(AttributeTableOfReal);
- ADD_ATTRID2FUNMAP_ITEM(AttributeTableOfString);
- ADD_ATTRID2FUNMAP_ITEM(AttributeLocalID);
- ADD_ATTRID2FUNMAP_ITEM(AttributePythonObject);
-
- ADD_ATTRID2FUNMAP_ITEM(AttributeUserID);
- ADD_ATTRID2FUNMAP_ITEM(AttributeTreeNode);
-
- ADD_ATTRID2FUNMAP_ITEM(AttributePersistentRef);
- ADD_ATTRID2FUNMAP_ITEM(AttributeDrawable);
- ADD_ATTRID2FUNMAP_ITEM(AttributeSelectable);
- ADD_ATTRID2FUNMAP_ITEM(AttributeExpandable);
- ADD_ATTRID2FUNMAP_ITEM(AttributeOpened);
- ADD_ATTRID2FUNMAP_ITEM(AttributeTextColor);
- ADD_ATTRID2FUNMAP_ITEM(AttributeTextHighlightColor);
- ADD_ATTRID2FUNMAP_ITEM(AttributePixMap);
- ADD_ATTRID2FUNMAP_ITEM(AttributeTarget);
- ADD_ATTRID2FUNMAP_ITEM(AttributeStudyProperties);
- ADD_ATTRID2FUNMAP_ITEM(AttributeExternalFileDef);
- ADD_ATTRID2FUNMAP_ITEM(AttributeFileType);
-
- ADD_ATTRID2FUNMAP_ITEM(AttributeGraphic);
- ADD_ATTRID2FUNMAP_ITEM(AttributeFlags);
-
- TAttrID2FunMap::const_iterator anIter = __AttrID2FunMap__.begin();
- TAttrID2FunMap::const_iterator anEnd = __AttrID2FunMap__.end();
- for(; anIter != anEnd; anIter++){
- const TAttrID2FunMap::key_type& aKey = anIter->first;
- const TAttrID2FunMap::data_type& aValue = anIter->second;
- __GUID2AttrIDMap__[aValue.myGetGUID()] = aKey;
- };
-
-#undef ADD_ATTRID2FUNMAP_ITEM
- return true;
- }
-
-
- static bool __IsInitilized__ = Init();
-
-
- //============================================================================
- bool GetAttrFun(const Standard_GUID& theGUID, TAttrFun& theAttrFun)
- {
- TGUID2AttrIDMap::const_iterator anIter = __GUID2AttrIDMap__.find(theGUID);
- if(anIter != __GUID2AttrIDMap__.end())
- {
- const TAttributeID& anAttributeID = anIter->second;
- TAttrID2FunMap::const_iterator anIter2 = __AttrID2FunMap__.find(anAttributeID);
- if(anIter2 != __AttrID2FunMap__.end())
- {
- theAttrFun = anIter2->second;
- return true;
- }
- }
- return false;
- }
-
-
- //============================================================================
- Standard_GUID GetGUID(const char* theType)
- {
- TAttrID2FunMap::const_iterator anIter = __AttrID2FunMap__.find(theType);
- if(anIter != __AttrID2FunMap__.end()){
- const TAttrID2FunMap::data_type& aValue = anIter->second;
- return aValue.myGetGUID();
- }
- // create tree node GUID by name
- if(strncmp(theType,"AttributeTreeNodeGUID",21) == 0){
- char aGUIDString[40] = "";
- sprintf(aGUIDString,&theType[21]);
- return aGUIDString;
- }
-
- return Standard_GUID();
- }
-
-
- //============================================================================
- std::string GetType(const Handle(TDF_Attribute)& theAttr)
- {
- if(theAttr.IsNull())
- return CORBA::string_dup("");
-
- Standard_GUID aGUID = theAttr->ID();
- TGUID2AttrIDMap::const_iterator anIter = __GUID2AttrIDMap__.find(aGUID);
- if(anIter != __GUID2AttrIDMap__.end())
- {
- const TAttributeID& anAttributeID = anIter->second;
- return anAttributeID;
- }
-
- char aType[60] = "";
- {
- Handle(TDataStd_TreeNode) anAttr = Handle(TDataStd_TreeNode)::DownCast(theAttr);
- if (!anAttr.IsNull()) {
- char aGUID[40] = "";
- anAttr->ID().ToCString(aGUID);
- sprintf(aType, "AttributeTreeNodeGUID%s",aGUID);
- return aType;
- }
- }
- {
- Handle(TDataStd_UAttribute) anAttr = Handle(TDataStd_UAttribute)::DownCast(theAttr);
- if (!anAttr.IsNull()) {
- char aGUID[40] = "";
- anAttr->ID().ToCString(aGUID);
- sprintf(aType, "AttributeUserID_%s",aGUID);
- return aType;
- }
- }
- return aType;
- }
-
-}
-
-//============================================================================
-SALOMEDS_Study_i::TSObjectHolder
-SALOMEDS_SObject_i::New(SALOMEDS_Study_i* theStudy,
- const TDF_Label& theLabel)