Panda3D
|
00001 // Filename: configVariableFilename.h 00002 // Created by: drose (22Nov04) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef CONFIGVARIABLEFILENAME_H 00016 #define CONFIGVARIABLEFILENAME_H 00017 00018 #include "dtoolbase.h" 00019 #include "configVariable.h" 00020 #include "filename.h" 00021 //////////////////////////////////////////////////////////////////// 00022 // Class : ConfigVariableFilename 00023 // Description : This is a convenience class to specialize 00024 // ConfigVariable as a Filename type. It is almost the 00025 // same thing as ConfigVariableString, except it handles 00026 // an implicit Filename::expand_from() operation so that 00027 // the user may put OS-specific filenames, or filenames 00028 // based on environment variables, in the prc file. 00029 //////////////////////////////////////////////////////////////////// 00030 class EXPCL_DTOOLCONFIG ConfigVariableFilename : public ConfigVariable { 00031 PUBLISHED: 00032 INLINE ConfigVariableFilename(const string &name); 00033 INLINE ConfigVariableFilename(const string &name, const Filename &default_value, 00034 const string &description = string(), int flags = 0); 00035 00036 INLINE void operator = (const Filename &value); 00037 INLINE operator const Filename &() const; 00038 00039 // These methods help the ConfigVariableFilename act like a Filename 00040 // object. 00041 INLINE const char *c_str() const; 00042 INLINE bool empty() const; 00043 INLINE size_t length() const; 00044 INLINE char operator [] (int n) const; 00045 00046 INLINE string get_fullpath() const; 00047 INLINE string get_dirname() const; 00048 INLINE string get_basename() const; 00049 INLINE string get_fullpath_wo_extension() const; 00050 INLINE string get_basename_wo_extension() const; 00051 INLINE string get_extension() const; 00052 00053 // Comparison operators are handy. 00054 INLINE bool operator == (const Filename &other) const; 00055 INLINE bool operator != (const Filename &other) const; 00056 INLINE bool operator < (const Filename &other) const; 00057 00058 INLINE void set_value(const Filename &value); 00059 INLINE Filename get_value() const; 00060 INLINE Filename get_default_value() const; 00061 00062 INLINE Filename get_word(int n) const; 00063 INLINE void set_word(int n, const Filename &value); 00064 00065 private: 00066 void reload_cache(); 00067 INLINE const Filename &get_ref_value() const; 00068 00069 private: 00070 AtomicAdjust::Integer _local_modified; 00071 Filename _cache; 00072 }; 00073 00074 #include "configVariableFilename.I" 00075 00076 #endif