0027067: Avoid use of virtual methods for implementation of destructors in legacy...
[occt.git] / src / MoniTool / MoniTool_OptValue.hxx
CommitLineData
42cf5bc1 1// Created on: 1999-12-17
2// Created by: Christian CAILLET
3// Copyright (c) 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 _MoniTool_OptValue_HeaderFile
18#define _MoniTool_OptValue_HeaderFile
19
20#include <Standard.hxx>
21#include <Standard_DefineAlloc.hxx>
22#include <Standard_Handle.hxx>
23
24#include <TCollection_AsciiString.hxx>
25#include <Standard_CString.hxx>
26#include <Standard_Boolean.hxx>
27class Standard_Transient;
28class MoniTool_Profile;
29
30
31//! This class allows two kinds of use
32//!
33//! As an object, a OptValue can be put in any operator or
34//! algorithm ... to use an Option of a Profile, by recording
35//! its value, hence avoiding to query the Profile eachtime
36//!
37//! This object brings a value which can be set as coming from a
38//! Profile, with a configuration name and for an Option name
39//! This value is evaluated then returned immediately
40//!
41//! As a class, it can be redefined to work on a dedicated
42//! Profile, provided by such or such specific way (as static
43//! context for instance)
44//!
45//! To change configuration, etc... can be done by querying and
46//! editing the Profile
47class MoniTool_OptValue
48{
49public:
50
51 DEFINE_STANDARD_ALLOC
52
53
54 //! Creates an OptValue on a given Option
55 //! This allows to use "shortcut" method to set the value
56 //!
57 //! WARNING : loading is not done at creation time. It must be
58 //! done explicitly by call to Load
59 //!
60 //! The reason comes from C++ : the Profile being virtual, and
61 //! intended to be redefined in sub-classes, must not be used in
62 //! the constructor. A separate method, called on the object
63 //! already created with its true type, must be called after
64 Standard_EXPORT MoniTool_OptValue(const Standard_CString opt = "");
65
66 //! Clears the Value of the OptValue
67 Standard_EXPORT void Clear();
68
69 //! Sets the value as coming from the Profile, according to an
70 //! Option name. Access as Fast or regular
71 //! If no value is available, the former one remains : can be
72 //! cleared by call to Clear
73 Standard_EXPORT void SetValue (const Handle(MoniTool_Profile)& prof, const Standard_CString opt, const Standard_Boolean fast = Standard_True);
74
75 //! Returns the Profile which can be used by Short Cut methods
76 //! Defaults returns a Null Handle, can be redefined
77 //! For instance, to return a static used as dictionary or context
78 Standard_EXPORT virtual Handle(MoniTool_Profile) Prof() const;
79
80 //! Sets the value from the Profile returned by method Prof,
81 //! and Option Name given at creation time.
82 //! FastValue by default, else Value
83 //!
84 //! Does not check if already loaded : reloads anyway
85 //! IsLoaded allows to test
86 Standard_EXPORT void Load (const Standard_Boolean fast = Standard_True);
87
88 //! Says if the OptValue is already loaded (i.e. Value defined)
89 Standard_EXPORT Standard_Boolean IsLoaded() const;
90
91 //! Returns the Value set by, either SetConf or SetValue
92 //! Can be Null ... (if not set or not properly set)
93 //!
94 //! Returned as Argument, hence avoiding DownCast
95 //! Warning : type is not controlled
96 Standard_EXPORT void Value (Handle(Standard_Transient)& val) const;
97
e6f550da 98 Standard_EXPORT virtual ~MoniTool_OptValue();
42cf5bc1 99
100private:
42cf5bc1 101 TCollection_AsciiString theopt;
102 Handle(Standard_Transient) theval;
42cf5bc1 103};
104
42cf5bc1 105#endif // _MoniTool_OptValue_HeaderFile