42cf5bc1 |
1 | // Created on: 1995-04-20 |
2 | // Created by: Tony GEORGIADES |
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 _Resource_Manager_HeaderFile |
18 | #define _Resource_Manager_HeaderFile |
19 | |
20 | #include <Standard.hxx> |
21 | #include <Standard_Type.hxx> |
22 | |
23 | #include <TCollection_AsciiString.hxx> |
24 | #include <Resource_DataMapOfAsciiStringAsciiString.hxx> |
25 | #include <Resource_DataMapOfAsciiStringExtendedString.hxx> |
26 | #include <Standard_Boolean.hxx> |
25e59720 |
27 | #include <Standard_Transient.hxx> |
42cf5bc1 |
28 | #include <Standard_CString.hxx> |
29 | #include <Standard_Integer.hxx> |
30 | #include <Standard_Real.hxx> |
31 | #include <Standard_ExtString.hxx> |
32 | class Standard_TypeMismatch; |
33 | class Resource_NoSuchResource; |
34 | class Standard_OutOfRange; |
35 | class TCollection_AsciiString; |
36 | |
37 | |
38 | class Resource_Manager; |
25e59720 |
39 | DEFINE_STANDARD_HANDLE(Resource_Manager, Standard_Transient) |
42cf5bc1 |
40 | |
41 | //! Defines a resource structure and its management methods. |
25e59720 |
42 | class Resource_Manager : public Standard_Transient |
42cf5bc1 |
43 | { |
44 | |
45 | public: |
46 | |
47 | |
48 | //! Create a Resource manager. |
49 | //! Attempts to find the two following files: |
50 | //! $CSF_`aName`Defaults/aName |
51 | //! $CSF_`aName`UserDefaults/aName |
52 | //! and load them respectively into a reference and a user resource structure. |
53 | //! |
54 | //! If CSF_ResourceVerbose defined, seeked files will be printed. |
55 | //! |
56 | //! FILE SYNTAX |
57 | //! The syntax of a resource file is a sequence of resource |
58 | //! lines terminated by newline characters or end of file. The |
59 | //! syntax of an individual resource line is: |
60 | Standard_EXPORT Resource_Manager(const Standard_CString aName, const Standard_Boolean Verbose = Standard_False); |
61 | |
62 | Standard_EXPORT Resource_Manager(const Standard_CString aName, TCollection_AsciiString& aDefaultsDirectory, TCollection_AsciiString& anUserDefaultsDirectory, const Standard_Boolean Verbose = Standard_False); |
63 | |
64 | //! Save the user resource structure in the specified file. |
65 | //! Creates the file if it does not exist. |
66 | Standard_EXPORT Standard_Boolean Save() const; |
67 | |
68 | //! returns True if the Resource does exist. |
69 | Standard_EXPORT Standard_Boolean Find (const Standard_CString aResource) const; |
70 | |
71 | //! Gets the value of an integer resource according to its |
72 | //! instance and its type. |
73 | Standard_EXPORT virtual Standard_Integer Integer (const Standard_CString aResourceName) const; |
74 | |
75 | //! Gets the value of a real resource according to its instance |
76 | //! and its type. |
77 | Standard_EXPORT virtual Standard_Real Real (const Standard_CString aResourceName) const; |
78 | |
79 | //! Gets the value of a CString resource according to its instance |
80 | //! and its type. |
81 | Standard_EXPORT virtual Standard_CString Value (const Standard_CString aResourceName) const; |
82 | |
83 | //! Gets the value of an ExtString resource according to its instance |
84 | //! and its type. |
85 | Standard_EXPORT virtual Standard_ExtString ExtValue (const Standard_CString aResourceName); |
86 | |
87 | //! Sets the new value of an integer resource. |
88 | //! If the resource does not exist, it is created. |
89 | Standard_EXPORT virtual void SetResource (const Standard_CString aResourceName, const Standard_Integer aValue); |
90 | |
91 | //! Sets the new value of a real resource. |
92 | //! If the resource does not exist, it is created. |
93 | Standard_EXPORT virtual void SetResource (const Standard_CString aResourceName, const Standard_Real aValue); |
94 | |
95 | //! Sets the new value of an CString resource. |
96 | //! If the resource does not exist, it is created. |
97 | Standard_EXPORT virtual void SetResource (const Standard_CString aResourceName, const Standard_CString aValue); |
98 | |
99 | //! Sets the new value of an ExtString resource. |
100 | //! If the resource does not exist, it is created. |
101 | Standard_EXPORT virtual void SetResource (const Standard_CString aResourceName, const Standard_ExtString aValue); |
102 | |
103 | //! Gets the resource file full path by its name. |
104 | //! If corresponding environment variable is not set |
105 | //! or file doesn't exist returns empty string. |
106 | Standard_EXPORT static void GetResourcePath (TCollection_AsciiString& aPath, const Standard_CString aName, const Standard_Boolean isUserDefaults); |
107 | |
108 | |
109 | |
110 | |
25e59720 |
111 | DEFINE_STANDARD_RTTIEXT(Resource_Manager,Standard_Transient) |
42cf5bc1 |
112 | |
113 | protected: |
114 | |
115 | |
116 | |
117 | |
118 | private: |
119 | |
120 | |
121 | Standard_EXPORT void Load (TCollection_AsciiString& aPath, Resource_DataMapOfAsciiStringAsciiString& aMap); |
122 | |
123 | TCollection_AsciiString myName; |
124 | Resource_DataMapOfAsciiStringAsciiString myRefMap; |
125 | Resource_DataMapOfAsciiStringAsciiString myUserMap; |
126 | Resource_DataMapOfAsciiStringExtendedString myExtStrMap; |
127 | Standard_Boolean myVerbose; |
128 | |
129 | |
130 | }; |
131 | |
132 | |
133 | |
134 | |
135 | |
136 | |
137 | |
138 | #endif // _Resource_Manager_HeaderFile |