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 
00026 struct CallFrame {
00027     string called_function;
00028     string filename;
00029     int linenumber;
00030 
00031     CallFrame (string f, int l, string func):
00032         called_function (func),
00033         filename (f),
00034         linenumber (l)
00035     {}
00036 };
00037 
00046 class ExecutionEnvironment {
00047 
00048 public:
00049     typedef vector<const CallFrame*> CallStack;
00050     
00051 private:
00052     int m_linenumber;
00053     string m_filename;
00054     bool m_forced_filename;
00055     YStatementPtr m_statement;
00056     CallStack m_backtrace;
00057 
00058 public:
00059     ExecutionEnvironment () : m_filename (""), m_forced_filename (false), m_statement(NULL) 
00060         { m_backtrace.clear (); };
00061     ~ExecutionEnvironment() {};
00062 
00066     int linenumber () const;
00067 
00071     void setLinenumber (int line);
00072 
00076     const string filename () const;
00077 
00081     void setFilename (const string & filename);
00082 
00086     YStatementPtr statement () const;
00087 
00091     void setStatement (YStatementPtr s);
00092 
00099     void pushframe (string called_function);
00100 
00104     void popframe ();
00105     
00112     void backtrace (loglevel_t level, uint skip = 0) const;
00113 
00120     CallStack callstack() const;
00121 };
00122 
00123 #endif /* _execution_environment_h */

Generated on Fri Jun 16 18:07:45 2006 for yast2-core by  doxygen 1.4.6