Subversion Repositories HomeAutomation

Rev

Rev 1601 | Rev 1604 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1601 Rev 1603
Line 20... Line 20...
20
 
20
 
21
#ifndef VM_MANAGER_H
21
#ifndef VM_MANAGER_H
22
#define VM_MANAGER_H
22
#define VM_MANAGER_H
23
 
23
 
24
#include <string>
24
#include <string>
25
#include <map>
25
#include <vector>
26
 
26
 
27
#include <boost/shared_ptr.hpp>
27
#include <boost/shared_ptr.hpp>
28
#include <v8.h>
28
#include <v8.h>
29
 
29
 
30
#include "logging/Logger.h"
30
#include "logging/Logger.h"
Line 36... Line 36...
36
namespace atom {
36
namespace atom {
37
namespace vm {
37
namespace vm {
38
 
38
 
39
class Manager : public common::IoService
39
class Manager : public common::IoService
40
{
40
{
41
    friend class Plugin;
-
 
42
 
-
 
43
public:
41
public:
44
    typedef boost::shared_ptr<Manager> Pointer;
42
    typedef boost::shared_ptr<Manager> Pointer;
45
   
43
   
46
    virtual ~Manager();
44
    virtual ~Manager();
47
   
45
   
48
    static Pointer Instance();
46
    static Pointer Instance();
49
    static void Create();
47
    static void Create();
50
    static void Delete();
48
    static void Delete();
51
   
49
   
52
    void AddPlugin(Plugin::Pointer plugin);
50
    void AddPlugin(Plugin::Pointer plugin);
53
   
51
   
54
    void Start(std::string script_path);
52
    void Start(std::string script_path);
55
    void Call(std::string name, ArgumentListPointer arguments);
53
    void Call(std::string name, ArgumentListPointer arguments);
56
    bool LoadScript(std::string scriptname);
54
    bool LoadScript(std::string scriptname);
-
 
55
    bool LoadScriptHandler(std::string scriptname);
57
   
56
   
58
private:
57
private:
59
    typedef std::map<std::string, Plugin::Pointer> PluginList;
58
    typedef std::vector<Plugin::Pointer> PluginList;
60
   
59
   
61
    static Pointer instance_;
60
    static Pointer instance_;
62
   
61
   
63
    std::string script_path_;
62
    std::string script_path_;
64
   
63
   
Line 66... Line 65...
66
    v8::HandleScope handle_scope_;
65
    v8::HandleScope handle_scope_;
67
    v8::Persistent<v8::ObjectTemplate> object_template_;
66
    v8::Persistent<v8::ObjectTemplate> object_template_;
68
   
67
   
69
    PluginList plugins_;
68
    PluginList plugins_;
70
    ImportFunctionList functions_;
69
    ImportFunctionList functions_;
71
   
70
   
72
    Manager();
71
    Manager();
73
   
72
   
74
    void StartHandler();
73
    void StartHandler();
75
    void CallHandler(std::string name, ArgumentListPointer arguments);
74
    void CallHandler(std::string name, ArgumentListPointer arguments);
76
    bool LoadScriptHandler(std::string scriptname);
-
 
77
   
75
   
78
    std::string FormatException(v8::TryCatch& try_catch);
76
    std::string FormatException(v8::TryCatch& try_catch);
79
   
77
   
80
    logging::Logger LOG;
78
    logging::Logger LOG;
81
};
79
};