]> granicus.if.org Git - icinga2/blob - lib/base/scriptframe.hpp
Merge pull request #7002 from Icinga/bugfix/check_network-percent-6155
[icinga2] / lib / base / scriptframe.hpp
1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2
3 #ifndef SCRIPTFRAME_H
4 #define SCRIPTFRAME_H
5
6 #include "base/i2-base.hpp"
7 #include "base/dictionary.hpp"
8 #include "base/array.hpp"
9 #include <boost/thread/tss.hpp>
10 #include <stack>
11
12 namespace icinga
13 {
14
15 struct ScriptFrame
16 {
17         Dictionary::Ptr Locals;
18         Value Self;
19         bool Sandboxed;
20         int Depth;
21
22         ScriptFrame(bool allocLocals);
23         ScriptFrame(bool allocLocals, Value self);
24         ~ScriptFrame();
25
26         void IncreaseStackDepth();
27         void DecreaseStackDepth();
28
29         static ScriptFrame *GetCurrentFrame();
30
31 private:
32         static boost::thread_specific_ptr<std::stack<ScriptFrame *> > m_ScriptFrames;
33
34         static void PushFrame(ScriptFrame *frame);
35         static ScriptFrame *PopFrame();
36
37         void InitializeFrame();
38 };
39
40 }
41
42 #endif /* SCRIPTFRAME_H */