ExecutionEnvironment.h

Go to the documentation of this file.
00001 /*
00002  * YaST2: Core system
00003  *
00004  * Description:
00005  *   YaST2 execution environment, i.e. processing context.
00006  *   Contains reference to the current block, the current statement,
00007  *   the current file name and backtrace.
00008  *   This information can be used for logging, debugger etc.
00009  *
00010  * Authors:
00011  *   Stanislav Visnovsky <visnov@suse.cz>
00012  *
00013  */
00014 
00015 #ifndef _execution_environment_h
00016 #define _execution_environment_h
00017 
00018 #include <stack>
00019 #include <string>
00020 
00021 #include "y2log.h"
00022 #include "ycp/YStatement.h"
00023 
00024 using namespace std;
00025 
00027 struct CallFrame {
00028     string called_function;
00029     string filename;
00030     int linenumber;
00031 
00032     CallFrame (string f, int l, string func):
00033         called_function (func),
00034         filename (f),
00035         linenumber (l)
00036     {}
00037 };
00038 
00047 class ExecutionEnvironment {
00048 
00049 public:
00050     typedef vector<const CallFrame*> CallStack;
00051     
00052 private:
00053     int m_linenumber;
00054     string m_filename;
00055     bool m_forced_filename;
00056     YStatementPtr m_statement;
00057     CallStack m_backtrace;
00058 
00059 public:
00060     ExecutionEnvironment () : m_filename (""), m_forced_filename (false), m_statement(NULL) 
00061         { m_backtrace.clear (); };
00062     ~ExecutionEnvironment() {};
00063 
00067     int linenumber () const;
00068 
00072     void setLinenumber (int line);
00073 
00077     const string filename () const;
00078 
00082     void setFilename (const string & filename);
00083 
00087     YStatementPtr statement () const;
00088 
00092     void setStatement (YStatementPtr s);
00093 
00100     void pushframe (string called_function);
00101 
00105     void popframe ();
00106     
00113     void backtrace (loglevel_t level, uint skip = 0) const;
00114 
00121     CallStack callstack() const;
00122 };
00123 
00124 #endif /* _execution_environment_h */

Generated on Tue Nov 6 01:20:21 2007 for yast2-core by  doxygen 1.5.0