Panda3D
Loading...
Searching...
No Matches
configVariableSearchPath.h
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file configVariableSearchPath.h
10 * @author drose
11 * @date 2004-10-21
12 */
13
14#ifndef CONFIGVARIABLESEARCHPATH_H
15#define CONFIGVARIABLESEARCHPATH_H
16
17#include "dtoolbase.h"
18#include "configVariableBase.h"
19#include "dSearchPath.h"
20
21/**
22 * This is similar to a ConfigVariableList, but it returns its list as a
23 * DSearchPath, as a list of directories.
24 *
25 * You may locally append directories to the end of the search path with the
26 * methods here, or prepend them to the beginning. Use these methods to make
27 * adjustments to the path; do not attempt to directly modify the const
28 * DSearchPath object returned by get_value().
29 *
30 * Unlike other ConfigVariable types, local changes (made by calling
31 * append_directory() and prepend_directory()) are specific to this particular
32 * instance of the ConfigVariableSearchPath. A separate instance of the same
33 * variable, created by using the same name to the constructor, will not
34 * reflect the local changes.
35 */
36class EXPCL_DTOOL_PRC ConfigVariableSearchPath : public ConfigVariableBase {
37PUBLISHED:
38 INLINE ConfigVariableSearchPath(const std::string &name,
39 const std::string &description = std::string(),
40 int flags = 0);
41 INLINE ConfigVariableSearchPath(const std::string &name,
42 const DSearchPath &default_value,
43 const std::string &description,
44 int flags = 0);
45 INLINE ConfigVariableSearchPath(const std::string &name,
46 const std::string &default_value,
47 const std::string &description,
48 int flags = 0);
49 INLINE ~ConfigVariableSearchPath();
50
51 INLINE operator DSearchPath () const;
52 INLINE DSearchPath get_value() const;
53 INLINE const DSearchPath &get_default_value() const;
54 MAKE_PROPERTY(value, get_value);
55 MAKE_PROPERTY(default_value, get_default_value);
56
57 INLINE bool clear_local_value();
58
59 INLINE void clear();
60 INLINE void append_directory(const Filename &directory);
61 INLINE void prepend_directory(const Filename &directory);
62 INLINE void append_path(const std::string &path,
63 const std::string &separator = std::string());
64 INLINE void append_path(const DSearchPath &path);
65 INLINE void prepend_path(const DSearchPath &path);
66
67 INLINE bool is_empty() const;
68 INLINE size_t get_num_directories() const;
69 INLINE Filename get_directory(size_t n) const;
70 MAKE_SEQ(get_directories, get_num_directories, get_directory);
71 MAKE_SEQ_PROPERTY(directories, get_num_directories, get_directory);
72
73 INLINE Filename find_file(const Filename &filename) const;
74 INLINE size_t find_all_files(const Filename &filename,
75 DSearchPath::Results &results) const;
76 INLINE DSearchPath::Results find_all_files(const Filename &filename) const;
77
78 INLINE void output(std::ostream &out) const;
79 INLINE void write(std::ostream &out) const;
80
81private:
82 void reload_search_path();
83
84 mutable MutexImpl _lock;
85 DSearchPath _default_value;
86 DSearchPath _prefix, _postfix;
87
88 AtomicAdjust::Integer _local_modified;
89 DSearchPath _cache;
90};
91
92INLINE std::ostream &operator << (std::ostream &out, const ConfigVariableSearchPath &variable);
93
95
96#endif
bool clear_local_value()
Removes the local value defined for this variable, and allows its value to be once again retrieved fr...
This is similar to a ConfigVariableList, but it returns its list as a DSearchPath,...
void clear()
Removes all the directories locally added to the search list, and restores it to its original form.
void prepend_path(const DSearchPath &path)
Adds all of the directories listed in the search path to the beginning of the search list.
void append_directory(const Filename &directory)
Adds a new directory to the end of the search list.
size_t find_all_files(const Filename &filename, DSearchPath::Results &results) const
Searches all the directories in the search list for the indicated file, in order.
void prepend_directory(const Filename &directory)
Adds a new directory to the front of the search list.
get_num_directories
Returns the number of directories on the search list.
bool is_empty() const
Returns true if the search list is empty, false otherwise.
get_directory
Returns the nth directory on the search list.
void append_path(const std::string &path, const std::string &separator=std::string())
Adds all of the directories listed in the search path to the end of the search list.
Filename find_file(const Filename &filename) const
Searches all the directories in the search list for the indicated file, in order.
This class stores a list of directories that can be searched, in order, to locate a particular file.
Definition dSearchPath.h:28
The name of a file, such as a texture file or an Egg file.
Definition filename.h:44
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.