PropertyVisitor.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 PropertyVisitor.cpp
22 
23  \brief Utility functions to register the PropertyVisitor class into the Google JavaScript V8 engine.
24  */
25 
26 // TerraLib
27 #include "../../../../dataaccess/property/PropertyVisitor.h"
28 #include "../../common/Utils.h"
29 #include "DataAccess.h"
30 
31 // Boost
32 #include <boost/cstdint.hpp>
33 
34 ::v8::Handle<::v8::Value> PropertyVisitor_Visit(const ::v8::Arguments& args)
35 {
36  return ::v8::Undefined();
37 }
38 
39 ::v8::Handle<::v8::Value> PropertyVisitor_Constructor(const ::v8::Arguments& args)
40 {
41  //::v8::HandleScope hs;
42 
43  //if(!args.IsConstructCall())
44  // return ::v8::ThrowException(::v8::String::New("In order to create a check constraint, you need to call its constructor like: var c = new TePropertyVisitor(dt, id);"));
45 
46  //if(args.Holder().IsEmpty())
47  // return ::v8::ThrowException(::v8::String::New("The PropertyVisitor constructor must use object notation!"));
48 
49  //if(args.Length() != 0)
50  // return ::v8::ThrowException(::v8::String::New("The PropertyVisitor constructor has no parameters!"));
51 
52  //std::auto_ptr<te::da::PropertyVisitor> catalog(new te::da::PropertyVisitor());
53 
54  //::v8::Local<::v8::Object> jcatalog = te::v8::common::Make(catalog.get(), te::v8::jsi::GetPropertyVisitorTemplate, true);
55 
56  //catalog.release();
57 
58  //return hs.Close(jcatalog);
59 
60  return ::v8::Undefined();
61 }
62 
63 void te::v8::jsi::RegisterPropertyVisitor(::v8::Local<::v8::Object>& global)
64 {
65  ::v8::Local<::v8::FunctionTemplate> jpropertyvisitor = ::v8::FunctionTemplate::New(PropertyVisitor_Constructor);
66 
67  global->Set(::v8::String::New("TePropertyVisitor"), jpropertyvisitor->GetFunction());
68 }
69 
70 static ::v8::Persistent<::v8::FunctionTemplate> sdset_propertyvisitor_template;
71 
72 ::v8::Persistent<::v8::FunctionTemplate>& te::v8::jsi::GetPropertyVisitorTemplate()
73 {
74  if(sdset_propertyvisitor_template.IsEmpty())
75  {
76  ::v8::Local<::v8::FunctionTemplate> result = ::v8::FunctionTemplate::New();
77  ::v8::Handle<::v8::ObjectTemplate> prototype = result->PrototypeTemplate();
78 
79  prototype->Set(::v8::String::NewSymbol("visit"), ::v8::FunctionTemplate::New(PropertyVisitor_Visit));
80 
81  sdset_propertyvisitor_template = ::v8::Persistent<::v8::FunctionTemplate>::New(result);
82  }
83 
85 }
::v8::Handle<::v8::Value > PropertyVisitor_Visit(const ::v8::Arguments &args)
::v8::Persistent<::v8::FunctionTemplate > & GetPropertyVisitorTemplate()
It returns a reference to the persistent template of a PropertyVisitor object.
void RegisterPropertyVisitor(::v8::Local<::v8::Object > &global)
It registers the PropertyVisitor class.
JavaScript exporting routine for the TerraLib Data Access module.
static::v8::Persistent<::v8::FunctionTemplate > sdset_propertyvisitor_template
::v8::Handle<::v8::Value > PropertyVisitor_Constructor(const ::v8::Arguments &args)