Panda3D
configVariableFilename.h
1 // Filename: configVariableFilename.h
2 // Created by: drose (22Nov04)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef CONFIGVARIABLEFILENAME_H
16 #define CONFIGVARIABLEFILENAME_H
17 
18 #include "dtoolbase.h"
19 #include "configVariable.h"
20 #include "filename.h"
21 ////////////////////////////////////////////////////////////////////
22 // Class : ConfigVariableFilename
23 // Description : This is a convenience class to specialize
24 // ConfigVariable as a Filename type. It is almost the
25 // same thing as ConfigVariableString, except it handles
26 // an implicit Filename::expand_from() operation so that
27 // the user may put OS-specific filenames, or filenames
28 // based on environment variables, in the prc file.
29 ////////////////////////////////////////////////////////////////////
30 class EXPCL_DTOOLCONFIG ConfigVariableFilename : public ConfigVariable {
31 PUBLISHED:
32  INLINE ConfigVariableFilename(const string &name);
33  INLINE ConfigVariableFilename(const string &name, const Filename &default_value,
34  const string &description = string(), int flags = 0);
35 
36  INLINE void operator = (const Filename &value);
37  INLINE operator const Filename &() const;
38 
39  // These methods help the ConfigVariableFilename act like a Filename
40  // object.
41  INLINE const char *c_str() const;
42  INLINE bool empty() const;
43  INLINE size_t length() const;
44  INLINE char operator [] (int n) const;
45 
46  INLINE string get_fullpath() const;
47  INLINE string get_dirname() const;
48  INLINE string get_basename() const;
49  INLINE string get_fullpath_wo_extension() const;
50  INLINE string get_basename_wo_extension() const;
51  INLINE string get_extension() const;
52 
53  // Comparison operators are handy.
54  INLINE bool operator == (const Filename &other) const;
55  INLINE bool operator != (const Filename &other) const;
56  INLINE bool operator < (const Filename &other) const;
57 
58  INLINE void set_value(const Filename &value);
59  INLINE Filename get_value() const;
60  INLINE Filename get_default_value() const;
61 
62  INLINE Filename get_word(int n) const;
63  INLINE void set_word(int n, const Filename &value);
64 
65 private:
66  void reload_cache();
67  INLINE const Filename &get_ref_value() const;
68 
69 private:
70  AtomicAdjust::Integer _local_modified;
71  Filename _cache;
72 };
73 
74 #include "configVariableFilename.I"
75 
76 #endif
This is a convenience class to specialize ConfigVariable as a Filename type.
const ConfigDeclaration * get_default_value() const
Returns the default variable specified for this variable.
This is a generic, untyped ConfigVariable.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44