Falaise  4.0.1
SuperNEMO Software Toolkit
resource.h
Go to the documentation of this file.
1 //! \file falaise/resource.h
2 //! \brief Utilities for accessing falaise resource/plugin files
3 //! \details The falaise library makes use of several resource files
4 //! containing isotopic and radioactive decays data.
5 //! Falaise also implements a plugin architecture, with
6 //! several supplied as core functionality.
7 //!
8 //! As these files are not compiled into the falaise library,
9 //! a simple API is provided to return the root paths to core
10 //! resource and plugin directories.
11 //!
12 //! These paths are calculated based on the location of the
13 //! Falaise library, allowing relocation of the Falaise
14 //! package after installation.
15 //!
16 //! If your application uses resources from Falaise,
17 //! you must call the falaise::init_resources function
18 //! before trying to access resources.
19 //
20 // Copyright (c) 2013-2016 by Ben Morgan <bmorgan.warwick@gmail.com>
21 // Copyright (c) 2013-2016 by The University of Warwick
22 //
23 // This file is part of falaise.
24 //
25 // falaise is free software: you can redistribute it and/or modify
26 // it under the terms of the GNU General Public License as published by
27 // the Free Software Foundation, either version 3 of the License, or
28 // (at your option) any later version.
29 //
30 // falaise is distributed in the hope that it will be useful,
31 // but WITHOUT ANY WARRANTY; without even the implied warranty of
32 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 // GNU General Public License for more details.
34 //
35 // You should have received a copy of the GNU General Public License
36 // along with falaise. If not, see <http://www.gnu.org/licenses/>.
37 
38 #ifndef FALAISE_RESOURCE_H
39 #define FALAISE_RESOURCE_H
40 // Standard Library
41 #include <stdexcept>
42 #include <string>
43 
44 // Third Party
45 // - A
46 
47 // This Project
48 
49 namespace falaise {
50 //! Exception class for bad resource initialization
51 class ResourceInitializationException : public std::runtime_error {
52  public:
53  ResourceInitializationException(const std::string& msg) : std::runtime_error(msg) {}
54 };
55 
56 //! Exception class for unknown resources
57 class UnknownResourceException : public std::runtime_error {
58  public:
59  UnknownResourceException(const std::string& msg) : std::runtime_error(msg) {}
60 };
61 
62 //! Initialize the library resource paths
63 //! \throw ResourceInitializationException when library cannot self locate
64 void init_resources();
65 
66 //! Return URL, i.e. a path, to the base directory where resource files are installed
67 std::string get_resource_dir();
68 
69 //! Return URL, i.e. a path, to named resource
70 std::string get_resource(const std::string& rname);
71 
72 //!//! Return URL, i.e. a path, to the base directory where plugin DLL files are installed
73 std::string get_plugin_dir();
74 
75 //! Return URL, i.e. a path, to named resource
76 std::string get_plugin(const std::string& rname);
77 
78 } // namespace falaise
79 
80 #endif // FALAISE_RESOURCE_H
std::string get_resource(const std::string &rname)
Return URL, i.e. a path, to named resource.
void init_resources()
std::string get_plugin(const std::string &rname)
Return URL, i.e. a path, to named resource.
std::string get_plugin_dir()
//! Return URL, i.e. a path, to the base directory where plugin DLL files are installed
ResourceInitializationException(const std::string &msg)
Definition: resource.h:53
Definition: metadata_utils.h:35
Exception class for unknown resources.
Definition: resource.h:57
std::string get_resource_dir()
Return URL, i.e. a path, to the base directory where resource files are installed.
Exception class for bad resource initialization.
Definition: resource.h:51
UnknownResourceException(const std::string &msg)
Definition: resource.h:59