1 // File: TObj_Persistence.cxx
2 // Created: Tue Nov 23 11:36:45 2004
3 // Author: Andrey BETENEV
4 // Copyright: Open CASCADE 2007
5 // The original implementation Copyright: (C) RINA S.p.A
7 #include <TObj_Persistence.hxx>
8 #include <TObj_Object.hxx>
10 //=======================================================================
11 //function : getMapOfTypes
12 //purpose : Returns the map of types
13 //=======================================================================
15 TObj_DataMapOfStringPointer& TObj_Persistence::getMapOfTypes ()
17 static TObj_DataMapOfStringPointer myMapOfTypes;
21 //=======================================================================
22 //function : Constructor
23 //purpose : Register the type for persistence
24 //=======================================================================
26 TObj_Persistence::TObj_Persistence (const Standard_CString theType)
29 getMapOfTypes().Bind ( theType, this );
32 //=======================================================================
33 //function : Destructor
34 //purpose : Unregister the type
35 //=======================================================================
37 TObj_Persistence::~TObj_Persistence ()
39 getMapOfTypes().UnBind ( myType );
42 //=======================================================================
43 //function : CreateNewObject
45 //=======================================================================
47 Handle(TObj_Object) TObj_Persistence::CreateNewObject (const Standard_CString theType,
48 const TDF_Label& theLabel)
50 if ( getMapOfTypes().IsBound ( theType ) )
52 TObj_Persistence *tool =
53 (TObj_Persistence*) getMapOfTypes().Find ( theType );
54 if ( tool ) return tool->New (theLabel);
59 //=======================================================================
60 //function : DumpTypes
62 //=======================================================================
64 void TObj_Persistence::DumpTypes (Standard_OStream &theOs)
66 TObj_DataMapOfStringPointer::Iterator it ( getMapOfTypes() );
67 for ( ; it.More(); it.Next() )
69 theOs << it.Key() << endl;