0028832: MMgt_TShared can be replaced by Standard_Transient
[occt.git] / src / StepData / StepData_Protocol.hxx
1 // Created on: 1993-02-03
2 // Created by: Christian CAILLET
3 // Copyright (c) 1993-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 _StepData_Protocol_HeaderFile
18 #define _StepData_Protocol_HeaderFile
19
20 #include <Standard.hxx>
21 #include <Standard_Type.hxx>
22
23 #include <Interface_DataMapOfTransientInteger.hxx>
24 #include <Interface_Protocol.hxx>
25 #include <Standard_Integer.hxx>
26 #include <Standard_Type.hxx>
27 #include <Standard_CString.hxx>
28 #include <Standard_Boolean.hxx>
29 #include <TColStd_SequenceOfAsciiString.hxx>
30 class Interface_Protocol;
31 class Standard_Transient;
32 class Interface_InterfaceModel;
33 class StepData_EDescr;
34 class StepData_ESDescr;
35 class StepData_ECDescr;
36 class StepData_PDescr;
37
38
39 class StepData_Protocol;
40 DEFINE_STANDARD_HANDLE(StepData_Protocol, Interface_Protocol)
41
42 //! Description of Basic Protocol for Step
43 //! The class Protocol from StepData itself describes a default
44 //! Protocol, which recognizes only UnknownEntities.
45 //! Sub-classes will redefine CaseNumber and, if necessary,
46 //! NbResources and Resources.
47 class StepData_Protocol : public Interface_Protocol
48 {
49
50 public:
51
52   
53   Standard_EXPORT StepData_Protocol();
54   
55   //! Gives the count of Protocols used as Resource (can be zero)
56   //! Here, No resource
57   Standard_EXPORT Standard_Integer NbResources() const Standard_OVERRIDE;
58   
59   //! Returns a Resource, given a rank. Here, none
60   Standard_EXPORT Handle(Interface_Protocol) Resource (const Standard_Integer num) const Standard_OVERRIDE;
61   
62   //! Returns a unique positive number for any recognized entity
63   //! Redefined to work by calling both TypeNumber and, for a
64   //! Described Entity (late binding) DescrNumber
65   Standard_EXPORT virtual Standard_Integer CaseNumber (const Handle(Standard_Transient)& obj) const Standard_OVERRIDE;
66   
67   //! Returns a Case Number, specific of each recognized Type
68   //! Here, only Unknown Entity is recognized
69   Standard_EXPORT Standard_Integer TypeNumber (const Handle(Standard_Type)& atype) const Standard_OVERRIDE;
70   
71   //! Returns the Schema Name attached to each class of Protocol
72   //! To be redefined by each sub-class
73   //! Here, SchemaName returns "(DEFAULT)"
74   //! was C++ : return const
75   Standard_EXPORT virtual Standard_CString SchemaName() const;
76   
77   //! Creates an empty Model for Step Norm
78   Standard_EXPORT Handle(Interface_InterfaceModel) NewModel() const Standard_OVERRIDE;
79   
80   //! Returns True if <model> is a Model of Step Norm
81   Standard_EXPORT Standard_Boolean IsSuitableModel (const Handle(Interface_InterfaceModel)& model) const Standard_OVERRIDE;
82   
83   //! Creates a new Unknown Entity for Step (UndefinedEntity)
84   Standard_EXPORT Handle(Standard_Transient) UnknownEntity() const Standard_OVERRIDE;
85   
86   //! Returns True if <ent> is an Unknown Entity for the Norm, i.e.
87   //! Type UndefinedEntity, status Unknown
88   Standard_EXPORT Standard_Boolean IsUnknownEntity (const Handle(Standard_Transient)& ent) const Standard_OVERRIDE;
89   
90   //! Returns a unique positive CaseNumber for types described by
91   //! an EDescr (late binding)
92   //! Warning : TypeNumber and DescrNumber must give together a unique
93   //! positive case number for each distinct case, type or descr
94   Standard_EXPORT virtual Standard_Integer DescrNumber (const Handle(StepData_EDescr)& adescr) const;
95   
96   //! Records an EDescr with its case number
97   //! Also records its name for an ESDescr (simple type): an ESDescr
98   //! is then used, for case number, or for type name
99   Standard_EXPORT void AddDescr (const Handle(StepData_EDescr)& adescr, const Standard_Integer CN);
100   
101   //! Tells if a Protocol brings at least one ESDescr, i.e. if it
102   //! defines at least one entity description by ESDescr mechanism
103   Standard_EXPORT Standard_Boolean HasDescr() const;
104   
105   //! Returns the description attached to a case number, or null
106   Standard_EXPORT Handle(StepData_EDescr) Descr (const Standard_Integer num) const;
107   
108   //! Returns a description according to its name
109   //! <anylevel> True (D) : for <me> and its resources
110   //! <anylevel> False : for <me> only
111   Standard_EXPORT Handle(StepData_EDescr) Descr (const Standard_CString name, const Standard_Boolean anylevel = Standard_True) const;
112   
113   //! Idem as Descr but cast to simple description
114   Standard_EXPORT Handle(StepData_ESDescr) ESDescr (const Standard_CString name, const Standard_Boolean anylevel = Standard_True) const;
115   
116   //! Returns a complex description according to list of names
117   //! <anylevel> True (D) : for <me> and its resources
118   //! <anylevel> False : for <me> only
119   Standard_EXPORT Handle(StepData_ECDescr) ECDescr (const TColStd_SequenceOfAsciiString& names, const Standard_Boolean anylevel = Standard_True) const;
120   
121   //! Records an PDescr
122   Standard_EXPORT void AddPDescr (const Handle(StepData_PDescr)& pdescr);
123   
124   //! Returns a parameter description according to its name
125   //! <anylevel> True (D) : for <me> and its resources
126   //! <anylevel> False : for <me> only
127   Standard_EXPORT Handle(StepData_PDescr) PDescr (const Standard_CString name, const Standard_Boolean anylevel = Standard_True) const;
128   
129   //! Records an ESDescr, intended to build complex descriptions
130   Standard_EXPORT void AddBasicDescr (const Handle(StepData_ESDescr)& esdescr);
131   
132   //! Returns a basic description according to its name
133   //! <anylevel> True (D) : for <me> and its resources
134   //! <anylevel> False : for <me> only
135   Standard_EXPORT Handle(StepData_EDescr) BasicDescr (const Standard_CString name, const Standard_Boolean anylevel = Standard_True) const;
136
137
138
139
140   DEFINE_STANDARD_RTTIEXT(StepData_Protocol,Interface_Protocol)
141
142 protected:
143
144
145
146
147 private:
148
149
150   Interface_DataMapOfTransientInteger thedscnum;
151   NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)> thedscnam;
152   NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)> thepdescr;
153   NCollection_DataMap<TCollection_AsciiString, Handle(Standard_Transient)> thedscbas;
154
155
156 };
157
158
159
160
161
162
163
164 #endif // _StepData_Protocol_HeaderFile