9e568278d3c4dd5f4b44e1e25c78518eb772f3c9
[occt.git] / src / TDataStd / TDataStd_Name.hxx
1 // Created on: 1997-07-31
2 // Created by: Denis PASCAL
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #ifndef _TDataStd_Name_HeaderFile
18 #define _TDataStd_Name_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22
23 #include <TCollection_ExtendedString.hxx>
24 #include <TDF_Attribute.hxx>
25 #include <Standard_OStream.hxx>
26 #include <Standard_GUID.hxx>
27
28 class Standard_DomainError;
29 class TDF_Label;
30 class TCollection_ExtendedString;
31 class TDF_Attribute;
32 class TDF_RelocationTable;
33
34
35 class TDataStd_Name;
36 DEFINE_STANDARD_HANDLE(TDataStd_Name, TDF_Attribute)
37
38 //! Used to define a name attribute containing a string which specifies the name.
39 class TDataStd_Name : public TDF_Attribute
40 {
41
42 public:
43
44   
45   //! class methods working on the name itself
46   //! ========================================
47   //! Returns the GUID for name attributes.
48   Standard_EXPORT static const Standard_GUID& GetID();
49   
50   //! Creates (if does not exist) and sets the name in the name attribute.
51   //! from any label <L>  search in father  labels (L is not
52   //! concerned) the first name attribute.if found set it in
53   //! <father>.
54   //! class methods working on the name tree
55   //! ======================================
56   //! Search in the  whole TDF_Data the Name attribute which
57   //! fit with <fullPath>. Returns True if found.
58   //! Search  under <currentLabel>  a  label which fit with
59   //! <name>. Returns True if  found. Shortcut which  avoids
60   //! building a ListOfExtendedStrin.
61   //! Search in the whole TDF_Data the label which fit with name
62   //! Returns True if found.
63   //! tools methods to translate path <-> pathlist
64   //! ===========================================
65   //! move to draw For Draw test we may provide this tool method which convert a path in a
66   //! sequence of string to call after the FindLabel methods.
67   //! Example: if it's given "Assembly:Part_1:Sketch_5" it will return in <pathlist>
68   //! the list of 3 strings: "Assembly","Part_1","Sketch_5".
69   //! move to draw from <pathlist> build the string path
70   //! Name methods
71   //! ============
72   Standard_EXPORT static Handle(TDataStd_Name) Set (const TDF_Label& label, const TCollection_ExtendedString& string);
73
74   //! Finds, or creates, a Name attribute with explicit user defined <guid> and sets <string>.
75   //! The Name attribute  is  returned. 
76   Standard_EXPORT static Handle(TDataStd_Name) Set (const TDF_Label& label, const Standard_GUID& guid,
77                                     const TCollection_ExtendedString& string);
78   Standard_EXPORT TDataStd_Name();
79   
80   //! Sets <S> as name. Raises if <S> is not a valid name.
81   Standard_EXPORT void Set (const TCollection_ExtendedString& S);
82   
83   //! Sets the explicit user defined GUID  to the attribute.
84   Standard_EXPORT void SetID (const Standard_GUID& guid) Standard_OVERRIDE;
85
86   //! Sets default GUID for the attribute.
87   Standard_EXPORT void SetID() Standard_OVERRIDE;
88
89   //! Returns the name contained in this name attribute.
90   Standard_EXPORT const TCollection_ExtendedString& Get() const;
91   
92   Standard_EXPORT const Standard_GUID& ID() const Standard_OVERRIDE;
93   
94   Standard_EXPORT void Restore (const Handle(TDF_Attribute)& with) Standard_OVERRIDE;
95   
96   Standard_EXPORT Handle(TDF_Attribute) NewEmpty() const Standard_OVERRIDE;
97   
98   Standard_EXPORT void Paste (const Handle(TDF_Attribute)& into, const Handle(TDF_RelocationTable)& RT) const Standard_OVERRIDE;
99   
100   Standard_EXPORT virtual Standard_OStream& Dump (Standard_OStream& anOS) const Standard_OVERRIDE;
101
102
103
104
105   DEFINE_STANDARD_RTTIEXT(TDataStd_Name,TDF_Attribute)
106
107 protected:
108
109
110
111
112 private:
113
114
115   TCollection_ExtendedString myString;
116   Standard_GUID myID;
117
118 };
119
120
121
122
123
124
125
126 #endif // _TDataStd_Name_HeaderFile