0031501: Foundation Classes, Message_Printer - remove theToPutEndl argument -- prepar...
[occt.git] / src / IFSelect / IFSelect_WorkLibrary.hxx
CommitLineData
42cf5bc1 1// Created on: 1993-01-08
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 _IFSelect_WorkLibrary_HeaderFile
18#define _IFSelect_WorkLibrary_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_Type.hxx>
22
23#include <Standard_Integer.hxx>
24#include <Interface_HArray1OfHAsciiString.hxx>
25#include <Standard_Transient.hxx>
26#include <Standard_CString.hxx>
27#include <Standard_Boolean.hxx>
28class Interface_InterfaceModel;
29class Interface_Protocol;
30class IFSelect_ContextWrite;
31class Interface_EntityIterator;
32class Interface_CopyTool;
33class Standard_Transient;
42cf5bc1 34
35class IFSelect_WorkLibrary;
36DEFINE_STANDARD_HANDLE(IFSelect_WorkLibrary, Standard_Transient)
37
38//! This class defines the (empty) frame which can be used to
39//! enrich a XSTEP set with new capabilities
40//! In particular, a specific WorkLibrary must give the way for
41//! Reading a File into a Model, and Writing a Model to a File
42//! Thus, it is possible to define several Work Libraries for each
43//! norm, but recommanded to define one general class for each one :
44//! this general class will define the Read and Write methods.
45//!
46//! Also a Dump service is provided, it can produce, according the
47//! norm, either a parcel of a file for an entity, or any other
48//! kind of informations relevant for the norm,
49class IFSelect_WorkLibrary : public Standard_Transient
50{
51
52public:
53
54
55 //! Gives the way to Read a File and transfer it to a Model
56 //! <mod> is the resulting Model, which has to be created by this
57 //! method. In case of error, <mod> must be returned Null
58 //! Return value is a status with free values.
59 //! Simply, 0 is for "Execution OK"
60 //! The Protocol can be used to work (e.g. create the Model, read
61 //! and recognize the Entities)
62 Standard_EXPORT virtual Standard_Integer ReadFile (const Standard_CString name, Handle(Interface_InterfaceModel)& model, const Handle(Interface_Protocol)& protocol) const = 0;
63
64 //! Gives the way to Write a File from a Model.
65 //! <ctx> contains all necessary informations : the model, the
66 //! protocol, the file name, and the list of File Modifiers to be
67 //! applied, also with restricted list of selected entities for
68 //! each one, if required.
69 //! In return, it brings the produced check-list
70 //!
71 //! The WorkLibrary has to query <applied> to get then run the
72 //! ContextWrite by looping like this (example) :
73 //! for (numap = 1; numap <= ctx.NbModifiers(); numap ++) {
74 //! ctx.SetModifier (numap);
75 //! cast ctx.FileModifier() to specific type -> variable filemod
76 //! if (!filemod.IsNull()) filemod->Perform (ctx,writer);
77 //! filemod then works with ctx. It can, either act on the
78 //! model itself (for instance on its header), or iterate
79 //! on selected entities (Start/Next/More/Value)
80 //! it can call AddFail or AddWarning, as necessary
81 //! }
82 Standard_EXPORT virtual Standard_Boolean WriteFile (IFSelect_ContextWrite& ctx) const = 0;
83
84 //! Performs the copy of entities from an original model to a new
85 //! one. It must also copy headers if any. Returns True when done.
86 //! The provided default works by copying the individual entities
87 //! designated in the list, by using the general service class
88 //! CopyTool.
89 //! It can be redefined for a norm which, either implements Copy
90 //! by another way (do not forget to Bind each copied result with
91 //! its original entity in TC) and returns True, or does not know
92 //! how to copy and returns False
93 Standard_EXPORT virtual Standard_Boolean CopyModel (const Handle(Interface_InterfaceModel)& original, const Handle(Interface_InterfaceModel)& newmodel, const Interface_EntityIterator& list, Interface_CopyTool& TC) const;
94
95 //! Gives the way of dumping an entity under a form comprehensive
96 //! for each norm. <model> helps to identify, number ... entities.
97 //! <level> is to be interpreted for each norm (because of the
98 //! formats which can be very different)
0ebe5b0a 99 Standard_EXPORT virtual void DumpEntity (const Handle(Interface_InterfaceModel)& model, const Handle(Interface_Protocol)& protocol, const Handle(Standard_Transient)& entity, Standard_OStream& S, const Standard_Integer level) const = 0;
42cf5bc1 100
101 //! Calls deferred DumpEntity with the recorded default level
0ebe5b0a 102 Standard_EXPORT void DumpEntity (const Handle(Interface_InterfaceModel)& model, const Handle(Interface_Protocol)& protocol, const Handle(Standard_Transient)& entity, Standard_OStream& S) const;
42cf5bc1 103
104 //! Records a default level and a maximum value for level
105 //! level for DumpEntity can go between 0 and <max>
106 //! default value will be <def>
107 Standard_EXPORT void SetDumpLevels (const Standard_Integer def, const Standard_Integer max);
108
109 //! Returns the recorded default and maximum dump levels
110 //! If none was recorded, max is returned negative, def as zero
111 Standard_EXPORT void DumpLevels (Standard_Integer& def, Standard_Integer& max) const;
112
113 //! Records a short line of help for a level (0 - max)
114 Standard_EXPORT void SetDumpHelp (const Standard_Integer level, const Standard_CString help);
115
116 //! Returns the help line recorded for <level>, or an empty string
117 Standard_EXPORT Standard_CString DumpHelp (const Standard_Integer level) const;
118
119
120
121
92efcf78 122 DEFINE_STANDARD_RTTIEXT(IFSelect_WorkLibrary,Standard_Transient)
42cf5bc1 123
124protected:
125
126
127 //! Required to initialise fields
128 Standard_EXPORT IFSelect_WorkLibrary();
129
130
131
132private:
133
134
135 Standard_Integer thelevdef;
136 Handle(Interface_HArray1OfHAsciiString) thelevhlp;
137
138
139};
140
141
142
143
144
145
146
147#endif // _IFSelect_WorkLibrary_HeaderFile