mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
add ConfigVariableFilename
This commit is contained in:
parent
ea51416fd6
commit
48c96d0928
@ -16,6 +16,7 @@
|
|||||||
configVariableCore.cxx configVariableCore.I configVariableCore.h \
|
configVariableCore.cxx configVariableCore.I configVariableCore.h \
|
||||||
configVariableDouble.cxx configVariableDouble.I configVariableDouble.h \
|
configVariableDouble.cxx configVariableDouble.I configVariableDouble.h \
|
||||||
configVariableEnum.cxx configVariableEnum.I configVariableEnum.h \
|
configVariableEnum.cxx configVariableEnum.I configVariableEnum.h \
|
||||||
|
configVariableFilename.cxx configVariableFilename.I configVariableFilename.h \
|
||||||
configVariableInt.cxx configVariableInt.I configVariableInt.h \
|
configVariableInt.cxx configVariableInt.I configVariableInt.h \
|
||||||
configVariableList.cxx configVariableList.I configVariableList.h \
|
configVariableList.cxx configVariableList.I configVariableList.h \
|
||||||
configVariableManager.cxx configVariableManager.I configVariableManager.h \
|
configVariableManager.cxx configVariableManager.I configVariableManager.h \
|
||||||
@ -40,6 +41,7 @@
|
|||||||
configVariableCore.I configVariableCore.h \
|
configVariableCore.I configVariableCore.h \
|
||||||
configVariableDouble.I configVariableDouble.h \
|
configVariableDouble.I configVariableDouble.h \
|
||||||
configVariableEnum.I configVariableEnum.h \
|
configVariableEnum.I configVariableEnum.h \
|
||||||
|
configVariableFilename.I configVariableFilename.h \
|
||||||
configVariableInt.I configVariableInt.h \
|
configVariableInt.I configVariableInt.h \
|
||||||
configVariableList.I configVariableList.h \
|
configVariableList.I configVariableList.h \
|
||||||
configVariableManager.I configVariableManager.h \
|
configVariableManager.I configVariableManager.h \
|
||||||
|
@ -34,6 +34,9 @@ operator << (ostream &out, ConfigFlags::ValueType type) {
|
|||||||
case ConfigFlags::VT_string:
|
case ConfigFlags::VT_string:
|
||||||
return out << "string";
|
return out << "string";
|
||||||
|
|
||||||
|
case ConfigFlags::VT_filename:
|
||||||
|
return out << "filename";
|
||||||
|
|
||||||
case ConfigFlags::VT_bool:
|
case ConfigFlags::VT_bool:
|
||||||
return out << "bool";
|
return out << "bool";
|
||||||
|
|
||||||
|
@ -34,6 +34,7 @@ PUBLISHED:
|
|||||||
VT_undefined,
|
VT_undefined,
|
||||||
VT_list,
|
VT_list,
|
||||||
VT_string,
|
VT_string,
|
||||||
|
VT_filename,
|
||||||
VT_bool,
|
VT_bool,
|
||||||
VT_int,
|
VT_int,
|
||||||
VT_double,
|
VT_double,
|
||||||
|
159
dtool/src/prc/configVariableFilename.I
Normal file
159
dtool/src/prc/configVariableFilename.I
Normal file
@ -0,0 +1,159 @@
|
|||||||
|
// Filename: configVariableFilename.I
|
||||||
|
// Created by: drose (22Nov04)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the Panda 3d
|
||||||
|
// Software license. You should have received a copy of this license
|
||||||
|
// along with this source code; you will also find a current copy of
|
||||||
|
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||||
|
//
|
||||||
|
// To contact the maintainers of this program write to
|
||||||
|
// panda3d-general@lists.sourceforge.net .
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ConfigVariableFilename::Constructor
|
||||||
|
// Access: Published
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE ConfigVariableFilename::
|
||||||
|
ConfigVariableFilename(const string &name) :
|
||||||
|
ConfigVariable(name, VT_filename)
|
||||||
|
{
|
||||||
|
_core->set_used();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ConfigVariableFilename::Constructor
|
||||||
|
// Access: Published
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE ConfigVariableFilename::
|
||||||
|
ConfigVariableFilename(const string &name, const Filename &default_value,
|
||||||
|
const string &description, int flags) :
|
||||||
|
ConfigVariable(name, VT_filename, description, flags)
|
||||||
|
{
|
||||||
|
_core->set_default_value(default_value);
|
||||||
|
_core->set_used();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ConfigVariableFilename::operator =
|
||||||
|
// Access: Published
|
||||||
|
// Description: Reassigns the variable's local value.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void ConfigVariableFilename::
|
||||||
|
operator = (const Filename &value) {
|
||||||
|
set_value(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ConfigVariableFilename::Filename typecast operator
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns the variable's value as a Filename.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE ConfigVariableFilename::
|
||||||
|
operator Filename () const {
|
||||||
|
return get_value();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ConfigVariableFilename::empty
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns true if the filename is empty, false otherwise.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE bool ConfigVariableFilename::
|
||||||
|
empty() const {
|
||||||
|
return get_value().empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ConfigVariableFilename::Equality operator
|
||||||
|
// Access: Public
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE bool ConfigVariableFilename::
|
||||||
|
operator == (const Filename &other) const {
|
||||||
|
return get_value() == other;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ConfigVariableFilename::Inequality operator
|
||||||
|
// Access: Public
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE bool ConfigVariableFilename::
|
||||||
|
operator != (const Filename &other) const {
|
||||||
|
return get_value() != other;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ConfigVariableFilename::Ordering operator
|
||||||
|
// Access: Public
|
||||||
|
// Description:
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE bool ConfigVariableFilename::
|
||||||
|
operator < (const Filename &other) const {
|
||||||
|
return get_value() < other;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ConfigVariableFilename::set_value
|
||||||
|
// Access: Published
|
||||||
|
// Description: Reassigns the variable's local value.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void ConfigVariableFilename::
|
||||||
|
set_value(const Filename &value) {
|
||||||
|
set_string_value(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ConfigVariableFilename::get_value
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns the variable's value.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE Filename ConfigVariableFilename::
|
||||||
|
get_value() const {
|
||||||
|
return Filename::expand_from(get_string_value());
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ConfigVariableFilename::get_default_value
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns the variable's default value.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE Filename ConfigVariableFilename::
|
||||||
|
get_default_value() const {
|
||||||
|
const ConfigDeclaration *decl = ConfigVariable::get_default_value();
|
||||||
|
if (decl != (ConfigDeclaration *)NULL) {
|
||||||
|
return decl->get_string_word(0);
|
||||||
|
}
|
||||||
|
return string();
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ConfigVariableFilename::get_word
|
||||||
|
// Access: Published
|
||||||
|
// Description: Returns the variable's nth value.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE Filename ConfigVariableFilename::
|
||||||
|
get_word(int n) const {
|
||||||
|
return Filename::expand_from(get_string_word(n));
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function: ConfigVariableFilename::set_word
|
||||||
|
// Access: Published
|
||||||
|
// Description: Reassigns the variable's nth value. This makes a
|
||||||
|
// local copy of the variable's overall value.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
INLINE void ConfigVariableFilename::
|
||||||
|
set_word(int n, const Filename &value) {
|
||||||
|
set_string_word(n, value);
|
||||||
|
}
|
19
dtool/src/prc/configVariableFilename.cxx
Normal file
19
dtool/src/prc/configVariableFilename.cxx
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// Filename: configVariableFilename.cxx
|
||||||
|
// Created by: drose (22Nov04)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the Panda 3d
|
||||||
|
// Software license. You should have received a copy of this license
|
||||||
|
// along with this source code; you will also find a current copy of
|
||||||
|
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||||
|
//
|
||||||
|
// To contact the maintainers of this program write to
|
||||||
|
// panda3d-general@lists.sourceforge.net .
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#include "configVariableFilename.h"
|
60
dtool/src/prc/configVariableFilename.h
Normal file
60
dtool/src/prc/configVariableFilename.h
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
// Filename: configVariableFilename.h
|
||||||
|
// Created by: drose (22Nov04)
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// PANDA 3D SOFTWARE
|
||||||
|
// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
|
||||||
|
//
|
||||||
|
// All use of this software is subject to the terms of the Panda 3d
|
||||||
|
// Software license. You should have received a copy of this license
|
||||||
|
// along with this source code; you will also find a current copy of
|
||||||
|
// the license at http://etc.cmu.edu/panda3d/docs/license/ .
|
||||||
|
//
|
||||||
|
// To contact the maintainers of this program write to
|
||||||
|
// panda3d-general@lists.sourceforge.net .
|
||||||
|
//
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef CONFIGVARIABLEFILENAME_H
|
||||||
|
#define CONFIGVARIABLEFILENAME_H
|
||||||
|
|
||||||
|
#include "dtoolbase.h"
|
||||||
|
#include "configVariable.h"
|
||||||
|
#include "filename.h"
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Class : ConfigVariableFilename
|
||||||
|
// Description : This is a convenience class to specialize
|
||||||
|
// ConfigVariable as a Filename type. It is almost the
|
||||||
|
// same thing as ConfigVariableString, except it handles
|
||||||
|
// an implicit Filename::expand_from() operation so that
|
||||||
|
// the user may put OS-specific filenames, or filenames
|
||||||
|
// based on environment variables, in the prc file.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
class EXPCL_DTOOLCONFIG ConfigVariableFilename : public ConfigVariable {
|
||||||
|
PUBLISHED:
|
||||||
|
INLINE ConfigVariableFilename(const string &name);
|
||||||
|
INLINE ConfigVariableFilename(const string &name, const Filename &default_value,
|
||||||
|
const string &description = string(), int flags = 0);
|
||||||
|
|
||||||
|
INLINE void operator = (const Filename &value);
|
||||||
|
INLINE operator Filename () const;
|
||||||
|
INLINE bool empty() const;
|
||||||
|
|
||||||
|
// Comparison operators are handy.
|
||||||
|
INLINE bool operator == (const Filename &other) const;
|
||||||
|
INLINE bool operator != (const Filename &other) const;
|
||||||
|
INLINE bool operator < (const Filename &other) const;
|
||||||
|
|
||||||
|
INLINE void set_value(const Filename &value);
|
||||||
|
INLINE Filename get_value() const;
|
||||||
|
INLINE Filename get_default_value() const;
|
||||||
|
|
||||||
|
INLINE Filename get_word(int n) const;
|
||||||
|
INLINE void set_word(int n, const Filename &value);
|
||||||
|
};
|
||||||
|
|
||||||
|
#include "configVariableFilename.I"
|
||||||
|
|
||||||
|
#endif
|
@ -35,7 +35,7 @@ ConfigVariableString(const string &name) :
|
|||||||
// Description:
|
// Description:
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
INLINE ConfigVariableString::
|
INLINE ConfigVariableString::
|
||||||
ConfigVariableString(const string &name, string default_value,
|
ConfigVariableString(const string &name, const string &default_value,
|
||||||
const string &description, int flags) :
|
const string &description, int flags) :
|
||||||
ConfigVariable(name, VT_string, description, flags)
|
ConfigVariable(name, VT_string, description, flags)
|
||||||
{
|
{
|
||||||
@ -63,19 +63,6 @@ operator string () const {
|
|||||||
return get_value();
|
return get_value();
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
// Function: ConfigVariableString::Filename typecast operator
|
|
||||||
// Access: Published
|
|
||||||
// Description: Returns the variable's value. This typecast operator
|
|
||||||
// is a convenience in case you happen to want to assign
|
|
||||||
// a ConfigVariableString into a Filename; C++ won't
|
|
||||||
// make the implicit typecast for you.
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
INLINE ConfigVariableString::
|
|
||||||
operator Filename () const {
|
|
||||||
return get_value();
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: ConfigVariableString::empty
|
// Function: ConfigVariableString::empty
|
||||||
// Access: Published
|
// Access: Published
|
||||||
|
@ -21,7 +21,6 @@
|
|||||||
|
|
||||||
#include "dtoolbase.h"
|
#include "dtoolbase.h"
|
||||||
#include "configVariable.h"
|
#include "configVariable.h"
|
||||||
#include "filename.h"
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Class : ConfigVariableString
|
// Class : ConfigVariableString
|
||||||
@ -31,12 +30,11 @@
|
|||||||
class EXPCL_DTOOLCONFIG ConfigVariableString : public ConfigVariable {
|
class EXPCL_DTOOLCONFIG ConfigVariableString : public ConfigVariable {
|
||||||
PUBLISHED:
|
PUBLISHED:
|
||||||
INLINE ConfigVariableString(const string &name);
|
INLINE ConfigVariableString(const string &name);
|
||||||
INLINE ConfigVariableString(const string &name, string default_value,
|
INLINE ConfigVariableString(const string &name, const string &default_value,
|
||||||
const string &description = string(), int flags = 0);
|
const string &description = string(), int flags = 0);
|
||||||
|
|
||||||
INLINE void operator = (const string &value);
|
INLINE void operator = (const string &value);
|
||||||
INLINE operator string () const;
|
INLINE operator string () const;
|
||||||
INLINE operator Filename () const;
|
|
||||||
INLINE bool empty() const;
|
INLINE bool empty() const;
|
||||||
|
|
||||||
// Comparison operators are handy.
|
// Comparison operators are handy.
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#include "notify.h"
|
#include "notify.h"
|
||||||
#include "notifyCategory.h"
|
#include "notifyCategory.h"
|
||||||
#include "configPageManager.h"
|
#include "configPageManager.h"
|
||||||
#include "configVariableString.h"
|
#include "configVariableFilename.h"
|
||||||
#include "configVariableBool.h"
|
#include "configVariableBool.h"
|
||||||
#include "filename.h"
|
#include "filename.h"
|
||||||
|
|
||||||
@ -527,7 +527,7 @@ config_initialized() {
|
|||||||
already_initialized = true;
|
already_initialized = true;
|
||||||
|
|
||||||
if (_ostream_ptr == &cerr) {
|
if (_ostream_ptr == &cerr) {
|
||||||
ConfigVariableString notify_output
|
ConfigVariableFilename notify_output
|
||||||
("notify-output", "",
|
("notify-output", "",
|
||||||
"The filename to which to write all the output of notify");
|
"The filename to which to write all the output of notify");
|
||||||
|
|
||||||
|
@ -89,6 +89,7 @@ ConfigVariableString
|
|||||||
ConfigVariableBool
|
ConfigVariableBool
|
||||||
ConfigVariableInt
|
ConfigVariableInt
|
||||||
ConfigVariableDouble
|
ConfigVariableDouble
|
||||||
|
ConfigVariableFilename
|
||||||
ConfigVariableEnum (C++ only)
|
ConfigVariableEnum (C++ only)
|
||||||
ConfigVariableList
|
ConfigVariableList
|
||||||
ConfigVariableSearchPath
|
ConfigVariableSearchPath
|
||||||
@ -96,9 +97,19 @@ ConfigVariableSearchPath
|
|||||||
These each define a config variable of the corresponding type. For
|
These each define a config variable of the corresponding type. For
|
||||||
instance, a ConfigVariableInt defines a variable whose value must
|
instance, a ConfigVariableInt defines a variable whose value must
|
||||||
always be an integer value. The most common variable types are the
|
always be an integer value. The most common variable types are the
|
||||||
top four, which are self-explanatory; the remaining three are special
|
top four, which are self-explanatory; the remaining four are special
|
||||||
types:
|
types:
|
||||||
|
|
||||||
|
ConfigVariableFilename -
|
||||||
|
|
||||||
|
This is a convenience class which behaves very much like a
|
||||||
|
ConfigVariableString, except that it automatically converts from
|
||||||
|
OS-specific filenames that may be given in the prc file to
|
||||||
|
Panda-specific filenames, and it also automatically expands
|
||||||
|
environment variable references, so that the user may name a file
|
||||||
|
based on the value of an environment variable
|
||||||
|
(e.g. $PANDAMODELS/file.egg).
|
||||||
|
|
||||||
ConfigVariableEnum -
|
ConfigVariableEnum -
|
||||||
|
|
||||||
This is a special template class available in C++ only. It provides
|
This is a special template class available in C++ only. It provides
|
||||||
|
Loading…
x
Reference in New Issue
Block a user