Subversion Repositories HomeAutomation

Rev

Rev 1625 | Rev 1947 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | SVN | RSS feed

  1. /*
  2.  *
  3.  *  Copyright (C) 2010  Mattias Runge
  4.  *
  5.  *  This program is free software; you can redistribute it and/or modify
  6.  *  it under the terms of the GNU General Public License as published by
  7.  *  the Free Software Foundation; either version 2 of the License, or
  8.  *  (at your option) any later version.
  9.  *
  10.  *  This program 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 General Public License for more details.
  14.  *
  15.  *  You should have received a copy of the GNU General Public License along
  16.  *  with this program; if not, write to the Free Software Foundation, Inc.,
  17.  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  18.  *
  19.  */
  20.  
  21. #ifndef VM_PLUGIN_H
  22. #define VM_PLUGIN_H
  23.  
  24. #include <string>
  25. #include <map>
  26. #include <vector>
  27.  
  28. #include <boost/shared_ptr.hpp>
  29. #include <boost/asio.hpp>
  30. #include <v8-debug.h>
  31.  
  32. #include "types.h"
  33.  
  34. namespace atom {
  35. namespace vm {
  36.  
  37. class Plugin
  38. {
  39. public:
  40.     typedef boost::shared_ptr<Plugin> Pointer;
  41.    
  42.     Plugin(boost::asio::io_service& io_service);
  43.     virtual ~Plugin();
  44.    
  45.     std::string GetName();
  46.     ExportFunctionList& GetExportFunctions();
  47.    
  48.     virtual void InitializeDone();
  49.     virtual void CallOutput(unsigned int request_id, std::string output);
  50.    
  51. protected:
  52.     typedef boost::shared_ptr<char> TrackerPointer;
  53.    
  54.     std::string name_;
  55.     TrackerPointer tracker_;
  56.     boost::asio::io_service& io_service_;
  57.    
  58.     bool Call(unsigned int request_id, std::string name, ArgumentListPointer arguments);
  59.     void Execute(unsigned int request_id, std::string code);
  60.     void ExportFunction(std::string name, v8::InvocationCallback function);
  61.     static bool ImportFunction(std::string name);
  62.    
  63. private:
  64.     ExportFunctionList export_functions_;
  65. };
  66.  
  67. }; // namespace vm
  68. }; // namespace atom
  69.  
  70. #endif // VM_PLUGIN_H
  71.