ApplicationData.h
Go to the documentation of this file.
1 // This file is a part of the OpenSurgSim project.
2 // Copyright 2013, SimQuest Solutions Inc.
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 // http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 
16 #ifndef SURGSIM_FRAMEWORK_APPLICATIONDATA_H
17 #define SURGSIM_FRAMEWORK_APPLICATIONDATA_H
18 
19 #include <string>
20 #include <vector>
21 
22 #if !defined(SURGSIM_PARSED_BY_DOXYGEN) // do not generate documentation for Boost stuff!
23 namespace boost
24 {
25 namespace filesystem
26 {
27 class path;
28 } // namespace filesystem
29 } // namespace boost
30 #endif // defined(SURGSIM_PARSED_BY_DOXYGEN)
31 
32 namespace SurgSim
33 {
34 namespace Framework
35 {
36 
40 {
41 public:
42 
48  explicit ApplicationData(const std::vector<std::string>& paths);
49 
52  explicit ApplicationData(const std::string& configFile);
53 
55 
59  std::vector<std::string> getPaths() const;
60 
68  std::string findFile(const std::string& fileName) const;
69 
76  bool tryFindFile(const std::string& fileName, std::string* target) const;
77 
81  bool isValidFilename(const std::string& fileName) const;
82 
83 private:
88  bool addPath(const std::string& pathName);
89 
95  bool setPaths(const std::vector<std::string>& paths);
96 
97  std::vector<boost::filesystem::path> m_paths;
98 };
99 
100 }; // Framework
101 }; // SurgSim
102 
103 #endif // SURGSIM_FRAMEWORK_APPLICATIONDATA_H
SurgSim::Framework::ApplicationData::getPaths
std::vector< std::string > getPaths() const
Gets the search paths.
Definition: ApplicationData.cpp:147
SurgSim::Framework::ApplicationData::~ApplicationData
~ApplicationData()
Definition: ApplicationData.cpp:56
SurgSim
Definition: CompoundShapeToGraphics.cpp:29
SurgSim::Framework::ApplicationData::tryFindFile
bool tryFindFile(const std::string &fileName, std::string *target) const
Searches for the first occurrence of fileName amongst the given paths, see findFile() for details.
Definition: ApplicationData.cpp:91
SurgSim::Framework::ApplicationData::m_paths
std::vector< boost::filesystem::path > m_paths
Definition: ApplicationData.h:97
SurgSim::Framework::ApplicationData::addPath
bool addPath(const std::string &pathName)
Adds a single path to the list of search paths.
Definition: ApplicationData.cpp:115
SurgSim::Framework::ApplicationData::findFile
std::string findFile(const std::string &fileName) const
Searches for the first occurrence of fileName amongst the given paths, the search is shallow,...
Definition: ApplicationData.cpp:60
SurgSim::Framework::ApplicationData::isValidFilename
bool isValidFilename(const std::string &fileName) const
Checks if the filename is acceptable.
Definition: ApplicationData.cpp:157
string
string(TOUPPER ${DEVICE} DEVICE_UPPER_CASE) option(BUILD_DEVICE_$
Definition: CMakeLists.txt:38
SurgSim::Framework::ApplicationData::setPaths
bool setPaths(const std::vector< std::string > &paths)
Sets the list of search paths to be used for finding the location of files.
Definition: ApplicationData.cpp:104
SurgSim::Framework::ApplicationData::ApplicationData
ApplicationData(const std::vector< std::string > &paths)
Constructor, class is immutable, pass a list of paths to be used for searching duplicate paths will b...
Definition: ApplicationData.cpp:31
SurgSim::Framework::ApplicationData
Enable searching for files in a given list of paths, give access to the current directory and wrap bo...
Definition: ApplicationData.h:39