TerraLib and TerraView Wiki Page

This is an old revision of the document!



Warning: Declaration of syntax_plugin_iframe::handle($match, $state, $pos, &$handler) should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in /var/www/html/terralib5/wiki/lib/plugins/iframe/syntax.php on line 18

Warning: Declaration of syntax_plugin_iframe::render($mode, &$R, $data) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in /var/www/html/terralib5/wiki/lib/plugins/iframe/syntax.php on line 18

Warning: Declaration of syntax_plugin_externallink::handle($match, $state, $pos, &$handler) should be compatible with DokuWiki_Syntax_Plugin::handle($match, $state, $pos, Doku_Handler $handler) in /var/www/html/terralib5/wiki/lib/plugins/externallink/syntax.php on line 107

Warning: Declaration of syntax_plugin_externallink::render($mode, &$renderer, $data) should be compatible with DokuWiki_Syntax_Plugin::render($format, Doku_Renderer $renderer, $data) in /var/www/html/terralib5/wiki/lib/plugins/externallink/syntax.php on line 107

TerraLib → Plugin

A classe AbstractPlugin define a interface básica das implementações de suporte a plugins. Todo plugin:

  • possui algumas informações básicas descritas pela estrutura PluginInfo;
  • sabe informar se a funcionalidade incorporada/adicionada pelo plugin já foi inicializada;
  • possibilita a realização de algum tipo de inicialização de suas funcionalidades após a carga do mesmo pela aplicação alvo;
  • possibilita a finalização dos recursos incorporados/adicionados antes do seu módulo ser liberado da memória.
class abstract_plugin : public boost::noncopyable
{
  public:
 
    //! Default constructor.
    abstract_plugin() { }
 
    //! Virtual destructor.
    virtual ~abstract_plugin() { }
 
    //! Plugin information.
    virtual const plugin_info_t& info() const = 0;
 
    //! Tells if the plugin has been started.
    virtual bool has_started() const = 0;
 
    //! This method will be called by applications to startup some plugin's functionality.
    /*!
      \exception plugin_startup_error It may throws an exception.
     */
    virtual void startup() = 0;
 
    //! This method will be called by applicatons to shutdown plugin's functionality.
    /*!
      \exception plugin_shutdown_error It may throws an exception.
     */
    virtual void shutdown() = 0;
};

Um plugin é descrito através de uma estrutura denominada PluginInfo. Esta estrutura contém os parâmetros essenciais para identificação e carga de um plugin, como o nome de uma biblioteca compartilhada a ser carregada dinamicamente, a lista de dependências de outros plugins e o identificador da máquina de carga do plugin.

struct PluginInfo
{
  std::string name;                      //!< The plugin name: an internal value used to identify the plugin in the system. Must be a unique value.
  std::string display_name;              //!< The plugin name to be displayed in a graphical interface.
  std::string description;               //!< A brief explanation about the plugin.
  std::string version;                   //!< The plugin version.
  std::string release;                   //!< The release date of the plugin. This may be used to identify new versions of a given plugin.
  std::string engine;                    //!< The type of plugin execution engine: C++, JAVA, LUA or any other supported engine.
  std::string license_description;       //!< A brief description about the plugin license.
  std::string license_URL;               //!< An URL where someone can find more information on the license.
  std::string site;                      //!< An URL pointing to the plugin site.
  provider_t provider;                   //!< Information about the plugin provider.
  std::vector<std::string> dependencies; //!< The list of required plugins in order to lunch the plugin.
  std::vector<Resource> resources;     //!< The list of resources used by plugin.
  std::vector<Parameter> parameters;   //!< Any configuration parameter that can be informed to plugin (map: parameter-name -> parameter-value).
  HostApplication host_application;   //!< Information about the host system. May be used to validate the plugin version.
};

As informações sobre o desenvolvedor/fornecedor do plugin são representadas pela estrutura Provider

struct Provider
{
  std::string name;   //!< Provider name: may be a person or a company.
  std::string site;   //!< The provider home page.
  std::string email;  //!< The provider contact e-mail.
};

HostApplication descreve informações sobre a aplicação para a qual o plugin foi escrito:

struct HostApplication
{
  std::string version;
};

Os recursos associados a um plugin são descritos por pares chave-valor:

typedef std::pair<std::string, std::string> Resource;

Os parâmetros associados a um plugin são descritos por pares chave-valor:

typedef std::pair<std::string, std::string> Parameter;