DataDirector API
DDD_PathManager.h
Go to the documentation of this file.
1 /*! \file DDD_PathManager.h
2 
3  \par Copyright Information
4 
5  Copyright (c) 2012 The DiSTI Corporation.<br>
6  11301 Corporate Blvd; Suite 100<br>
7  Orlando, Florida 32817<br>
8  USA<br>
9  <br>
10  All rights reserved.<br>
11 
12  This Software contains proprietary trade secrets of DiSTI and may not be
13 reproduced, in whole or part, in any form, or by any means of electronic,
14 mechanical, or otherwise, without the written permission of DiSTI. Said
15 permission may be derived through the purchase of applicable DiSTI product
16 licenses which detail the distribution rights of this content and any
17 Derivative Works based on this or other copyrighted DiSTI Software.
18 
19  NO WARRANTY. THE SOFTWARE IS PROVIDED "AS-IS," WITHOUT WARRANTY OF ANY KIND,
20 AND ANY USE OF THIS SOFTWARE PRODUCT IS AT YOUR OWN RISK. TO THE MAXIMUM EXTENT
21 PERMITTED BY APPLICABLE LAW, DISTI AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES
22 AND CONDITIONS, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
23 IMPLIED WARRANTIES AND CONDITIONS OF MERCHANTABILITY AND/OR FITNESS FOR A
24 PARTICULAR PURPOSE, TITLE, AND NON-INFRINGEMENT, WITH REGARD TO THE SOFTWARE.
25 
26  LIMITATION OF LIABILITY. TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW,
27 IN NO EVENT SHALL DISTI OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
28 INDIRECT, OR CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION,
29 DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS
30 INFORMATION, OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR
31 INABILITY TO USE THE SOFTWARE, EVEN IF DISTI HAS BEEN ADVISED OF THE POSSIBLITY
32 OF SUCH DAMAGES. DISTI'S ENTIRE LIABILITY AND YOUR EXCLUSIVE REMEDY SHALL NOT
33 EXCEED FIVE DOLLARS (US$5.00).
34 
35  The aforementioned terms and restrictions are governed by the laws of the
36 State of Florida and the United States of America.
37 
38 */
39 
40 #ifndef DDD_PATH_MANAGER_H_
41 #define DDD_PATH_MANAGER_H_
42 
43 #include <string>
44 #include "DDD_Include.h"
45 
46 namespace disti
47 {
48 
49 /** The DDD_PathManager class allows the application to handle multiple base paths for relative path access.
50  * For example, the location of the assets and converters are relative to that of the application, but
51  * the RSOs loaded by a .ddd file would be relative to the file. This class is easily accessible anywhere where
52  * DataDirector apps are created, so the right working directory can be accessed appropriately whenever relative
53  * paths may be encountered.
54  */
55 class DDD_EXPORT DDD_PathManager
56 {
57 private:
58  /** Constructor - private to ensure singleton-only access*/
60 
61 public:
62  /** singleton interface */
63  static DDD_PathManager& Instance();
64 
65  /** Destructor */
66  ~DDD_PathManager();
67 
68  /** Is path a relative path?
69  * \param path Path string to check
70  * \return true if given path string is a relative path
71  */
72  static bool IsPathRelative(const std::string& pathStr);
73 
74  /** Is path a absolute path?
75  * \param path Path string to check
76  * \return true if given path string is an absolute path
77  */
78  static bool IsPathAbsolute(const std::string& pathStr);
79 
80  /** Checks given path string (whether relative or absolute) to determine if given path or file exists
81  * \param path Path string to check
82  * \return true if given path string is a valid path
83  */
84  static bool IsPathValid(const std::string& pathStr);
85 
86  /** Attempts to convert the relative path to an absolute path
87  * \param pathStr Path string to convert
88  * \param absPath Absolute path returned by method
89  */
90  bool MakeAbsolutePath(const std::string& pathStr, std::string& absPath);
91 
92  /** Sets the loaded DDD config path (.ddd) file
93  * \param path Absolute path to config file
94  */
95  void DDDConfigPath(const std::string& pathStr);
96 
97  /** \return The absolute path to the loaded DDD config (.ddd file), if available */
98  std::string DDDConfigPath();
99 
100  /** Gets the relative path from DDD configuration file
101  * \param absPath Absolute pathname
102  * \return Path string relative to that of the DDD file
103  */
104  std::string GetRelativePathFromDDDConfig(const std::string& absPath);
105 
106  /** Sets the calling application path
107  * \param path Absolute path to calling application
108  */
109  void CallingAppPath(const std::string& path);
110 
111  /** \return The absolute path to the calling application */
112  std::string CallingAppPath();
113 
114  /** Gets the relative path from calling app
115  * \param absPath Absolute pathname
116  * \return Path string relative to that of the calling app
117  */
118  std::string GetRelativePathFromCallingApp(const std::string& absPath);
119 };
120 
121 
122 } // end namespace disti
123 
124 
125 #endif // DDD_PATH_MANAGER_H_
Definition: DDD_PathManager.h:55
Definition: AttributeChangedEmitter.h:46