Panda3D
|
00001 // Filename: configVariableSearchPath.h 00002 // Created by: drose (21Oct04) 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 CONFIGVARIABLESEARCHPATH_H 00016 #define CONFIGVARIABLESEARCHPATH_H 00017 00018 #include "dtoolbase.h" 00019 #include "configVariableBase.h" 00020 #include "dSearchPath.h" 00021 00022 //////////////////////////////////////////////////////////////////// 00023 // Class : ConfigVariableSearchPath 00024 // Description : This is similar to a ConfigVariableList, but it 00025 // returns its list as a DSearchPath, as a list of 00026 // directories. 00027 // 00028 // You may locally append directories to the end of the 00029 // search path with the methods here, or prepend them to 00030 // the beginning. Use these methods to make adjustments 00031 // to the path; do not attempt to directly modify the 00032 // const DSearchPath object returned by get_value(). 00033 // 00034 // Unlike other ConfigVariable types, local changes 00035 // (made by calling append_directory() and 00036 // prepend_directory()) are specific to this particular 00037 // instance of the ConfigVariableSearchPath. A separate 00038 // instance of the same variable, created by using the 00039 // same name to the constructor, will not reflect the 00040 // local changes. 00041 //////////////////////////////////////////////////////////////////// 00042 class EXPCL_DTOOLCONFIG ConfigVariableSearchPath : public ConfigVariableBase { 00043 PUBLISHED: 00044 INLINE ConfigVariableSearchPath(const string &name, 00045 const string &description = string(), 00046 int flags = 0); 00047 INLINE ConfigVariableSearchPath(const string &name, 00048 const DSearchPath &default_value, 00049 const string &description, 00050 int flags = 0); 00051 INLINE ConfigVariableSearchPath(const string &name, 00052 const string &default_value, 00053 const string &description, 00054 int flags = 0); 00055 INLINE ~ConfigVariableSearchPath(); 00056 00057 INLINE operator const DSearchPath & () const; 00058 INLINE const DSearchPath &get_value() const; 00059 INLINE const DSearchPath &get_default_value() const; 00060 00061 INLINE bool clear_local_value(); 00062 00063 INLINE void clear(); 00064 INLINE void append_directory(const Filename &directory); 00065 INLINE void prepend_directory(const Filename &directory); 00066 INLINE void append_path(const string &path, 00067 const string &separator = string()); 00068 INLINE void append_path(const DSearchPath &path); 00069 INLINE void prepend_path(const DSearchPath &path); 00070 00071 INLINE bool is_empty() const; 00072 INLINE int get_num_directories() const; 00073 INLINE const Filename &get_directory(int n) const; 00074 MAKE_SEQ(get_directories, get_num_directories, get_directory); 00075 00076 INLINE Filename find_file(const Filename &filename) const; 00077 INLINE int find_all_files(const Filename &filename, 00078 DSearchPath::Results &results) const; 00079 INLINE DSearchPath::Results find_all_files(const Filename &filename) const; 00080 00081 INLINE void output(ostream &out) const; 00082 INLINE void write(ostream &out) const; 00083 00084 private: 00085 void reload_search_path(); 00086 00087 DSearchPath _default_value; 00088 DSearchPath _prefix, _postfix; 00089 00090 AtomicAdjust::Integer _local_modified; 00091 DSearchPath _cache; 00092 }; 00093 00094 INLINE ostream &operator << (ostream &out, const ConfigVariableSearchPath &variable); 00095 00096 #include "configVariableSearchPath.I" 00097 00098 #endif