NCBI C++ ToolKit
sys_path.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_WX___SYS_PATH__HPP
2 #define GUI_WIDGETS_WX___SYS_PATH__HPP
3 
4 /* $Id: sys_path.hpp 33237 2015-06-19 20:28:12Z katargir $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Robert G. Smith, Michael DiCuccio
30  *
31  * File Description:
32  * CSysPath -- System dependent functions needed by the GUI framework
33  * File Description:
34  */
35 
36 #include <corelib/ncbistd.hpp>
37 #include <gui/gui.hpp>
38 
39 // This header must (at least indirectly) precede any wxWidgets headers.
41 
42 #include <wx/string.h>
43 
44 class wxStandardPathsBase;
45 
47 
48 // This class replaces CSystemPath
49 // It uses wxStrings and wxWidgets API and is UNICODE capable
50 //
51 
53 {
54 public:
55  /// Bind an alias to an existing path
56  /// The application expects certain aliases to be present; if they are
57  /// not provided, reasonable defaults will be used. Note that this
58  /// function is not thread-safe by design; application aliases shall
59  /// be created in a single thread at application start-up.
60  /// Possible aliases include:
61  /// '<std>' = location of the application installation
62  /// '<home>' = application- and user-specific data directory
63  /// '<res>' = location of the standard resource directory
64  /// '<pkgdir>' = location of package installation
65  static void BindAlias(const wxString& alias, const wxString& path);
66 
67  /// Utility function to hide the platform specifics of locating our
68  /// standard directories and files. This function is responsible for
69  /// resolving '<std>', '<home>', and '<res>' correctly.
70  static wxString ResolvePath(const wxString& path, const wxString& rel_name);
71 
72  /// Call the two paramter ResolvePath after splitting the path.
73  static wxString ResolvePath(const wxString& path);
74 
75  /// Utility function to hide the platform specifics of locating our
76  /// standard directories. This function is responsible for resolving
77  /// '<std>', '<home>', and '<res>' correctly, and further ensures that
78  /// the relevant final name already exists as a file or directory.
79  /// The 'path' parameter here contains a delimited set of directories
80  /// to search in order.
81  static wxString ResolvePathExisting(const wxString& path,
82  const wxString& delim = wxT(","));
83 
84  /// the applicaton installation directory. Usually the parent of the
85  /// App Path.
86  /// corresponds to the <std> alias above.
87  static wxString GetStdPath(void);
88 
89  /// the user-specific application-specific home directory
90  /// corresponds to the <home> alias above.
91  static wxString GetHomePath(void);
92 
93  /// the shared resource path
94  /// corresponds to the <res> alias above.
95  static wxString GetResourcePath(void);
96 
97  /// Add an element to the environment's PATH variable. This will make
98  /// sure that the element is inserted in the approrpiate place, and will
99  /// erase any occurrences of the path in the existing value
100  enum EPathMode {
102  ePath_Append
103  };
104  static void AddToPath(const wxString& path, EPathMode mode = ePath_Prepend);
105 
106  static void SetInst(const string& inst);
107  static string GetInst();
108 
109 protected:
110  static wxStandardPathsBase& GetStandardPaths();
111 
112 private:
115 
116  static string sm_Inst;
117 };
118 
120 
121 
122 #endif // GUI_WIDGETS_WX___SYS_PATH__HPP
EPathMode
Add an element to the environment's PATH variable.
Definition: sys_path.hpp:100
@ ePath_Prepend
Definition: sys_path.hpp:101
static string sm_Inst
Definition: sys_path.hpp:116
map< wxString, wxString > TAliasMap
Definition: sys_path.hpp:113
static TAliasMap sm_AliasMap
Definition: sys_path.hpp:114
Definition: map.hpp:338
Include a standard set of the NCBI C++ Toolkit most basic headers.
string GetStdPath(const string &path)
Definition: fileutil.cpp:291
Workaround for wxWidgets header errors in certain configurations; MUST be included (at least indirect...
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define NCBI_GUIWIDGETS_WX_EXPORT
Definition: gui_export.h:543
#define wxT(x)
Definition: muParser.cpp:41
mdb_mode_t mode
Definition: lmdb++.h:38
Modified on Wed Sep 04 15:04:02 2024 by modify_doxy.py rev. 669887