Subversion Repositories HomeAutomation

Rev

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

Rev 1619 Rev 1625
Line 30... Line 30...
30
namespace vm {
30
namespace vm {
31
namespace plugin {
31
namespace plugin {
32
 
32
 
33
logging::Logger Storage::LOG("vm::plugin::storage");
33
logging::Logger Storage::LOG("vm::plugin::storage");
34
   
34
   
35
Storage::Storage()
35
Storage::Storage(boost::asio::io_service& io_service) : Plugin(io_service)
36
{
36
{
37
    this->name_ = "storage";
37
    this->name_ = "storage";
38
   
38
   
39
    this->ExportFunction("Storage_GetParameters", Storage::Export_GetParameters);
39
    this->ExportFunction("Storage_GetParameters", Storage::Export_GetParameters);
40
    this->ExportFunction("Storage_GetParameter",  Storage::Export_GetParameter);
40
    this->ExportFunction("Storage_GetParameter",  Storage::Export_GetParameter);
Line 75... Line 75...
75
    return params;
75
    return params;
76
}
76
}
77
 
77
 
78
Value Storage::Export_GetParameter(const v8::Arguments& args)
78
Value Storage::Export_GetParameter(const v8::Arguments& args)
79
{
79
{
-
 
80
    v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext());
-
 
81
   
80
    LOG.Debug(std::string(__FUNCTION__) + " called!");
82
    LOG.Debug(std::string(__FUNCTION__) + " called!");
81
   
83
   
82
    if (args.Length() < 2)
84
    if (args.Length() < 2)
83
    {
85
    {
84
        LOG.Error("To few arguments.");
86
        LOG.Error("To few arguments.");
85
    }
87
    }
86
   
88
   
87
    v8::String::AsciiValue store_name(args[0]);
89
    v8::String::AsciiValue store_name(args[0]);
88
    v8::String::AsciiValue parameter_name(args[1]);
90
    v8::String::AsciiValue parameter_name(args[1]);
89
   
91
   
90
    Value result;
92
    Value result;
91
   
93
   
92
    try
94
    try
93
    {
95
    {
94
        result = v8::String::New(storage::Manager::Instance()->GetParameter(*store_name, *parameter_name).data());
96
        result = v8::String::New(storage::Manager::Instance()->GetParameter(*store_name, *parameter_name).data());
95
    }
97
    }
96
    catch (std::runtime_error& e)
98
    catch (std::runtime_error& e)
97
    {
99
    {
98
        result = v8::Undefined();
100
        result = v8::Undefined();
99
    }
101
    }
100
   
102
   
101
    return result;
103
    return result;
102
}
104
}
103
 
105
 
104
Value Storage::Export_SetParameter(const v8::Arguments& args)
106
Value Storage::Export_SetParameter(const v8::Arguments& args)
105
{
107
{
-
 
108
    v8::Context::Scope context_scope(vm::Manager::Instance()->GetContext());
-
 
109
   
106
    LOG.Debug(std::string(__FUNCTION__) + " called!");
110
    LOG.Debug(std::string(__FUNCTION__) + " called!");
107
   
111
   
108
    if (args.Length() < 3)
112
    if (args.Length() < 3)
109
    {
113
    {
110
        LOG.Error("To few arguments.");
114
        LOG.Error("To few arguments.");