Panda3D
 All Classes Functions Variables Enumerations
configVariableFilename.cxx
1 // Filename: configVariableFilename.cxx
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 #include "configVariableFilename.h"
16 #include "executionEnvironment.h"
17 
18 ////////////////////////////////////////////////////////////////////
19 // Function: ConfigVariableFilename::reload_cache
20 // Access: Private
21 // Description: Recopies the config variable into the Filename for
22 // returning its value.
23 ////////////////////////////////////////////////////////////////////
24 void ConfigVariableFilename::
25 reload_cache() {
26  nassertv(_core != (ConfigVariableCore *)NULL);
27  mark_cache_valid(_local_modified);
28 
29  const ConfigDeclaration *decl = _core->get_declaration(0);
30  const ConfigPage *page = decl->get_page();
31 
32  Filename page_filename(page->get_name());
33  Filename page_dirname = page_filename.get_dirname();
34  ExecutionEnvironment::shadow_environment_variable("THIS_PRC_DIR", page_dirname.to_os_specific());
35 
36  _cache = Filename::expand_from(decl->get_string_value());
37  ExecutionEnvironment::clear_shadow("THIS_PRC_DIR");
38 }
The internal definition of a ConfigVariable.
const string & get_string_value() const
Returns the value assigned to this variable.
string get_dirname() const
Returns the directory part of the filename.
Definition: filename.I:424
static Filename expand_from(const string &user_string, Type type=T_general)
Returns the same thing as from_os_specific(), but embedded environment variable references (e...
Definition: filename.cxx:418
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
A page of ConfigDeclarations that may be loaded or unloaded.
Definition: configPage.h:33
ConfigPage * get_page() const
Returns the page on which this declaration can be found.
static void clear_shadow(const string &var)
Removes a value set by a previous call to shadow_environment_variable(), and lets the actual value of...
const string & get_name() const
Returns the name of the page.
Definition: configPage.I:44
A single declaration of a config variable, typically defined as one line in a .prc file...
static void shadow_environment_variable(const string &var, const string &value)
Changes the apparent definition of the indicated environment variable by masking it within this class...