Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:04:42

0001 // Created on: 1995-04-20
0002 // Created by: Tony GEORGIADES
0003 // Copyright (c) 1995-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016 
0017 #ifndef _Resource_Manager_HeaderFile
0018 #define _Resource_Manager_HeaderFile
0019 
0020 #include <Standard.hxx>
0021 #include <Standard_Type.hxx>
0022 
0023 #include <TCollection_AsciiString.hxx>
0024 #include <Resource_DataMapOfAsciiStringAsciiString.hxx>
0025 #include <Resource_DataMapOfAsciiStringExtendedString.hxx>
0026 #include <Standard_Boolean.hxx>
0027 #include <Standard_Transient.hxx>
0028 #include <Standard_CString.hxx>
0029 #include <Standard_Integer.hxx>
0030 #include <Standard_Real.hxx>
0031 
0032 
0033 class Resource_Manager;
0034 DEFINE_STANDARD_HANDLE(Resource_Manager, Standard_Transient)
0035 
0036 //! Defines a resource structure and its management methods.
0037 class Resource_Manager : public Standard_Transient
0038 {
0039   DEFINE_STANDARD_RTTIEXT(Resource_Manager,Standard_Transient)
0040 public:
0041 
0042   //! Create a Resource manager.
0043   //! Attempts to find the two following files:
0044   //! $CSF_`aName`Defaults/aName
0045   //! $CSF_`aName`UserDefaults/aName
0046   //! and load them respectively into a reference and a user resource structure.
0047   //!
0048   //! If CSF_ResourceVerbose defined, seeked files will be printed.
0049   //!
0050   //! FILE SYNTAX
0051   //! The syntax of a resource file is a sequence of resource
0052   //! lines terminated by newline characters or end of file.  The
0053   //! syntax of an individual resource line is:
0054   Standard_EXPORT Resource_Manager(const Standard_CString aName, const Standard_Boolean Verbose = Standard_False);
0055 
0056   //! Create an empty Resource manager
0057   Standard_EXPORT Resource_Manager();
0058 
0059   //! Create a Resource manager.
0060   //! @param theName [in] description file name
0061   //! @param theDefaultsDirectory  [in] default folder for looking description file
0062   //! @param theUserDefaultsDirectory [in] user folder for looking description file
0063   //! @param theIsVerbose [in] print verbose messages
0064   Standard_EXPORT Resource_Manager (const TCollection_AsciiString& theName,
0065                                     const TCollection_AsciiString& theDefaultsDirectory,
0066                                     const TCollection_AsciiString& theUserDefaultsDirectory,
0067                                     const Standard_Boolean theIsVerbose = Standard_False);
0068   
0069   //! Save the user resource structure in the specified file.
0070   //! Creates the file if it does not exist.
0071   Standard_EXPORT Standard_Boolean Save() const;
0072   
0073   //! returns True if the Resource does exist.
0074   Standard_EXPORT Standard_Boolean Find (const Standard_CString aResource) const;
0075 
0076   //! returns True if the Resource does exist.
0077   Standard_EXPORT Standard_Boolean Find (const TCollection_AsciiString& theResource,
0078                                          TCollection_AsciiString& theValue) const;
0079 
0080   //! Gets the value of an integer resource according to its
0081   //! instance and its type.
0082   Standard_EXPORT virtual Standard_Integer Integer (const Standard_CString aResourceName) const;
0083   
0084   //! Gets the value of a real resource according to its instance
0085   //! and its type.
0086   Standard_EXPORT virtual Standard_Real Real (const Standard_CString aResourceName) const;
0087   
0088   //! Gets the value of a CString resource according to its instance
0089   //! and its type.
0090   Standard_EXPORT virtual Standard_CString Value (const Standard_CString aResourceName) const;
0091   
0092   //! Gets the value of an ExtString resource according to its instance
0093   //! and its type.
0094   Standard_EXPORT virtual Standard_ExtString ExtValue (const Standard_CString aResourceName);
0095   
0096   //! Sets the new value of an integer resource.
0097   //! If the resource does not exist, it is created.
0098   Standard_EXPORT virtual void SetResource (const Standard_CString aResourceName, const Standard_Integer aValue);
0099   
0100   //! Sets the new value of a real resource.
0101   //! If the resource does not exist, it is created.
0102   Standard_EXPORT virtual void SetResource (const Standard_CString aResourceName, const Standard_Real aValue);
0103   
0104   //! Sets the new value of an CString resource.
0105   //! If the resource does not exist, it is created.
0106   Standard_EXPORT virtual void SetResource (const Standard_CString aResourceName, const Standard_CString aValue);
0107   
0108   //! Sets the new value of an ExtString resource.
0109   //! If the resource does not exist, it is created.
0110   Standard_EXPORT virtual void SetResource (const Standard_CString aResourceName, const Standard_ExtString aValue);
0111   
0112   //! Gets the resource file full path by its name.
0113   //! If corresponding environment variable is not set
0114   //! or file doesn't exist returns empty string.
0115   Standard_EXPORT static void GetResourcePath (TCollection_AsciiString& aPath, const Standard_CString aName, const Standard_Boolean isUserDefaults);
0116 
0117   //! Returns internal Ref or User map with parameters 
0118   Standard_EXPORT Resource_DataMapOfAsciiStringAsciiString& GetMap(Standard_Boolean theRefMap = Standard_True);
0119   
0120 private:
0121 
0122   Standard_EXPORT void Load (const TCollection_AsciiString& thePath,
0123                              Resource_DataMapOfAsciiStringAsciiString& aMap);
0124 
0125 private:
0126 
0127   TCollection_AsciiString myName;
0128   Resource_DataMapOfAsciiStringAsciiString myRefMap;
0129   Resource_DataMapOfAsciiStringAsciiString myUserMap;
0130   Resource_DataMapOfAsciiStringExtendedString myExtStrMap;
0131   Standard_Boolean myVerbose;
0132 
0133 };
0134 
0135 #endif // _Resource_Manager_HeaderFile