0027349: XtControl_Reader is not thread-safe
[occt.git] / src / Interface / Interface_Category.hxx
CommitLineData
42cf5bc1 1// Created on: 1995-11-08
2// Created by: Christian CAILLET
3// Copyright (c) 1995-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 _Interface_Category_HeaderFile
18#define _Interface_Category_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_DefineAlloc.hxx>
22#include <Standard_Handle.hxx>
23
24#include <TColStd_HArray1OfInteger.hxx>
25#include <Standard_Integer.hxx>
26#include <Standard_CString.hxx>
7f56eba8 27
28#include <Interface_GTool.hxx>
42cf5bc1 29class Interface_Protocol;
30class Standard_Transient;
31class Interface_ShareTool;
32class Interface_InterfaceModel;
33
42cf5bc1 34//! This class manages categories
35//! A category is defined by a name and a number, and can be
36//! seen as a way of rough classification, i.e. less precise than
37//! a cdl type.
38//! Hence, it is possible to dispatch every entity in about
39//! a dozen of categories, twenty is a reasonable maximum.
40//!
41//! Basically, the system provides the following categories :
42//! Shape (Geometry, BRep, CSG, Features, etc...)
43//! Drawing (Drawing, Views, Annotations, Pictures, Scketches ...)
44//! Structure (Component & Part, Groups & Patterns ...)
45//! Description (Meta-Data : Relations, Properties, Product ...)
46//! Auxiliary (those which do not enter in the above list)
47//! and some dedicated categories
48//! FEA , Kinematics , Piping , etc...
49//! plus Professional for other dedicated non-classed categories
50//!
51//! In addition, this class provides a way to compute then quickly
52//! query category numbers for an entire model.
53//! Values are just recorded as a list of numbers, control must
54//! then be done in a wider context (which must provide a Graph)
55class Interface_Category
56{
7f56eba8 57 public:
42cf5bc1 58
59 DEFINE_STANDARD_ALLOC
60
42cf5bc1 61 //! Creates a Category, with no protocol yet
7f56eba8 62 Interface_Category()
63 : myGTool(new Interface_GTool)
64 { Init(); }
65
42cf5bc1 66 //! Creates a Category with a given protocol
7f56eba8 67 Interface_Category(const Handle(Interface_Protocol)& theProtocol)
68 : myGTool(new Interface_GTool(theProtocol))
69 { Init(); }
70
42cf5bc1 71 //! Creates a Category with a given GTool
7f56eba8 72 Interface_Category(const Handle(Interface_GTool)& theGTool)
73 : myGTool(theGTool)
74 { Init(); }
75
42cf5bc1 76 //! Sets/Changes Protocol
7f56eba8 77 void SetProtocol (const Handle(Interface_Protocol)& theProtocol)
78 { myGTool->SetProtocol(theProtocol); }
79
42cf5bc1 80 //! Determines the Category Number for an entity in its context,
81 //! by using general service CategoryNumber
7f56eba8 82 Standard_EXPORT Standard_Integer CatNum (const Handle(Standard_Transient)& theEnt, const Interface_ShareTool& theShares);
83
42cf5bc1 84 //! Clears the recorded list of category numbers for a Model
7f56eba8 85 void ClearNums()
86 { myNum.Nullify(); }
87
42cf5bc1 88 //! Computes the Category Number for each entity and records it,
89 //! in an array (ent.number -> category number)
90 //! Hence, it can be queried by the method Num.
91 //! The Model itself is not recorded, this method is intended to
92 //! be used in a wider context (which detains also a Graph, etc)
7f56eba8 93 Standard_EXPORT void Compute (const Handle(Interface_InterfaceModel)& theModel, const Interface_ShareTool& theShares);
94
42cf5bc1 95 //! Returns the category number recorded for an entity number
96 //! Returns 0 if out of range
7f56eba8 97 Standard_EXPORT Standard_Integer Num (const Standard_Integer theNumEnt) const;
98
42cf5bc1 99 //! Records a new Category defined by its names, produces a number
100 //! New if not yet recorded
7f56eba8 101 Standard_EXPORT static Standard_Integer AddCategory (const Standard_CString theName);
102
42cf5bc1 103 //! Returns the count of recorded categories
104 Standard_EXPORT static Standard_Integer NbCategories();
7f56eba8 105
42cf5bc1 106 //! Returns the name of a category, according to its number
7f56eba8 107 Standard_EXPORT static Standard_CString Name (const Standard_Integer theNum);
108
42cf5bc1 109 //! Returns the number of a category, according to its name
7f56eba8 110 Standard_EXPORT static Standard_Integer Number (const Standard_CString theName);
111
42cf5bc1 112 //! Default initialisation
113 //! (protected against several calls : passes only once)
114 Standard_EXPORT static void Init();
115
7f56eba8 116 private:
42cf5bc1 117
7f56eba8 118 Handle(Interface_GTool) myGTool;
119 Handle(TColStd_HArray1OfInteger) myNum;
42cf5bc1 120};
121
42cf5bc1 122#endif // _Interface_Category_HeaderFile