src/terralib/binding/v8/jsi/dataaccess/BatchExecutor.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2008 National Institute For Space Research (INPE) - Brazil.
2 
3  This file is part of the TerraLib - a Framework for building GIS enabled applications.
4 
5  TerraLib is free software: you can redistribute it and/or modify
6  it under the terms of the GNU Lesser General Public License as published by
7  the Free Software Foundation, either version 3 of the License,
8  or (at your option) any later version.
9 
10  TerraLib is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public License
16  along with TerraLib. See COPYING. If not, write to
17  TerraLib Team at <terralib-team@terralib.org>.
18  */
19 
20 /*!
21  \file BatchExecutor.cpp
22 
23  \brief Utility functions to register the BatchExecutor class into Google JavaScript V8 engine.
24  */
25 
26 // TerraLib
27 #include "../../../../dataaccess/datasource/BatchExecutor.h"
28 #include "../../common/Utils.h"
29 #include "DataAccess.h"
30 
31 ::v8::Handle<::v8::Value> BatchExecutor_Add(const ::v8::Arguments& /*args*/)
32 {
33  return ::v8::Undefined();
34 }
35 
36 ::v8::Handle<::v8::Value> BatchExecutor_Execute(const ::v8::Arguments& args)
37 {
38  te::da::BatchExecutor* bexec = te::v8::common::Unwrap<te::da::BatchExecutor>(args.Holder());
39 
40  if(bexec == 0)
41  return ::v8::ThrowException(::v8::String::New("Invalid batch executor in the execute method!"));
42 
43  bexec->execute();
44 
45  return ::v8::Undefined();
46 }
47 
48 ::v8::Handle<::v8::Value> BatchExecutor_GetTransactor(const ::v8::Arguments& /*args*/)
49 {
50  return ::v8::Undefined();
51 }
52 
53 static ::v8::Persistent<::v8::FunctionTemplate> sg_batchexecutor_template;
54 
55 ::v8::Persistent<::v8::FunctionTemplate>& te::v8::jsi::GetBatchExecutorTemplate()
56 {
57  if(sg_batchexecutor_template.IsEmpty())
58  {
59  ::v8::Local<::v8::FunctionTemplate> result = ::v8::FunctionTemplate::New();
60  ::v8::Handle<::v8::ObjectTemplate> prototype = result->PrototypeTemplate();
61 
62  prototype->Set(::v8::String::NewSymbol("add"), ::v8::FunctionTemplate::New(BatchExecutor_Add));
63  prototype->Set(::v8::String::NewSymbol("execute"), ::v8::FunctionTemplate::New(BatchExecutor_Execute));
64  prototype->Set(::v8::String::NewSymbol("getTransactor"), ::v8::FunctionTemplate::New(BatchExecutor_GetTransactor));
65 
66  sg_batchexecutor_template = ::v8::Persistent<::v8::FunctionTemplate>::New(result);
67  }
68 
70 }
71 
::v8::Handle<::v8::Value > BatchExecutor_GetTransactor(const ::v8::Arguments &)
JavaScript exporting routine for the TerraLib Data Access module.
::v8::Handle<::v8::Value > BatchExecutor_Add(const ::v8::Arguments &)
::v8::Persistent<::v8::FunctionTemplate > & GetBatchExecutorTemplate()
It returns a reference to the persistent template of a BatchExecutor object.
::v8::Handle<::v8::Value > BatchExecutor_Execute(const ::v8::Arguments &args)
A class that models an object that submits commands in batch to the data source.
static::v8::Persistent<::v8::FunctionTemplate > sg_batchexecutor_template
virtual void execute()=0