Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

dtool/src/dtoolutil/executionEnvironment.h

Go to the documentation of this file.
00001 // Filename: executionEnvironment.h
00002 // Created by:  drose (15May00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef EXECUTIONENVIRONMENT_H
00020 #define EXECUTIONENVIRONMENT_H
00021 
00022 #include <dtoolbase.h>
00023 
00024 #include "vector_string.h"
00025 #include "filename.h"
00026 
00027 #include <map>
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //       Class : ExecutionEnvironment
00031 // Description : Encapsulates access to the environment variables and
00032 //               command-line arguments at the time of execution.
00033 //               This is encapsulated to support accessing these
00034 //               things during static init time, which seems to be
00035 //               risky at best.
00036 ////////////////////////////////////////////////////////////////////
00037 class EXPCL_DTOOL ExecutionEnvironment {
00038 private:
00039   ExecutionEnvironment();
00040 
00041 public:
00042   INLINE static bool has_environment_variable(const string &var);
00043   INLINE static string get_environment_variable(const string &var);
00044   INLINE static void set_environment_variable(const string &var, const string &value);
00045 
00046   static string expand_string(const string &str);
00047 
00048   INLINE static int get_num_args();
00049   INLINE static string get_arg(int n);
00050 
00051   INLINE static string get_binary_name();
00052 
00053   static Filename get_cwd();
00054 
00055 private:
00056   bool ns_has_environment_variable(const string &var) const;
00057   string ns_get_environment_variable(const string &var) const;
00058   void ns_set_environment_variable(const string &var, const string &value);
00059 
00060   int ns_get_num_args() const;
00061   string ns_get_arg(int n) const;
00062 
00063   string ns_get_binary_name() const;
00064 
00065   static ExecutionEnvironment *get_ptr();
00066 
00067   void read_environment_variables();
00068   void read_args();
00069 
00070 private:
00071   typedef map<string, string> EnvironmentVariables;
00072   EnvironmentVariables _variables;
00073 
00074   typedef vector_string CommandArguments;
00075   CommandArguments _args;
00076 
00077   string _binary_name;
00078 
00079   static ExecutionEnvironment *_global_ptr;
00080 };
00081 
00082 #include "executionEnvironment.I"
00083 
00084 #endif

Generated on Thu May 1 22:12:59 2003 for DTool by doxygen1.3