Panda3D
configVariableFilename.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 configVariableFilename.h
10  * @author drose
11  * @date 2004-11-22
12  */
13 
14 #ifndef CONFIGVARIABLEFILENAME_H
15 #define CONFIGVARIABLEFILENAME_H
16 
17 #include "dtoolbase.h"
18 #include "configVariable.h"
19 #include "filename.h"
20 /**
21  * This is a convenience class to specialize ConfigVariable as a Filename
22  * type. It is almost the same thing as ConfigVariableString, except it
23  * handles an implicit Filename::expand_from() operation so that the user may
24  * put OS-specific filenames, or filenames based on environment variables, in
25  * the prc file.
26  */
27 class EXPCL_DTOOL_PRC ConfigVariableFilename : public ConfigVariable {
28 PUBLISHED:
29  INLINE ConfigVariableFilename(const std::string &name);
30  INLINE ConfigVariableFilename(const std::string &name, const Filename &default_value,
31  const std::string &description = std::string(), int flags = 0);
32 
33  INLINE void operator = (const Filename &value);
34  INLINE operator const Filename &() const;
35 
36  // These methods help the ConfigVariableFilename act like a Filename object.
37  INLINE const char *c_str() const;
38  INLINE bool empty() const;
39  INLINE size_t length() const;
40  INLINE char operator [] (size_t n) const;
41 
42  INLINE std::string get_fullpath() const;
43  INLINE std::string get_dirname() const;
44  INLINE std::string get_basename() const;
45  INLINE std::string get_fullpath_wo_extension() const;
46  INLINE std::string get_basename_wo_extension() const;
47  INLINE std::string get_extension() const;
48 
49  // Comparison operators are handy.
50  INLINE bool operator == (const Filename &other) const;
51  INLINE bool operator != (const Filename &other) const;
52  INLINE bool operator < (const Filename &other) const;
53 
54  INLINE void set_value(const Filename &value);
55  INLINE Filename get_value() const;
56  INLINE Filename get_default_value() const;
57  MAKE_PROPERTY(value, get_value, set_value);
58  MAKE_PROPERTY(default_value, get_default_value);
59 
60  INLINE Filename get_word(size_t n) const;
61  INLINE void set_word(size_t n, const Filename &value);
62 
63 private:
64  void reload_cache();
65  INLINE const Filename &get_ref_value() const;
66 
67 private:
68  AtomicAdjust::Integer _local_modified;
69  Filename _cache;
70 };
71 
72 #include "configVariableFilename.I"
73 
74 #endif
This is a convenience class to specialize ConfigVariable as a Filename type.
This is a generic, untyped ConfigVariable.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:39
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.