Remoto - VFS: pamPlugin Class Reference
Remoto - VFS
pamPlugin Class Reference

#include <VFS_pamPlugin.h>

Inheritance diagram for pamPlugin:
VFS_node_interface

Public Member Functions

virtual QString arguments (QString type)
 Describe the arguments needed to create a node. More...
 
virtual VFS_nodecreate (QString type, QVariantMap env, QDomElement child)
 Create a new node instance. More...
 
virtual QString description (QString type)
 Descriptive text about an individual node. More...
 
virtual bool initialize ()
 The plugin initializer. More...
 
virtual QStringList provides ()
 A string list of node names that this plugin is prepared to create. More...
 
- Public Member Functions inherited from VFS_node_interface
virtual ~VFS_node_interface ()
 
virtual QString code (QString nodename, QString libname, QString &error)
 Request code or other resource from a plugin bundle. More...
 
QString describe ()
 Describe all the nodes in a plugin. More...
 
bool isRemote ()
 If a plugin represents a remote resource, this value will be true. More...
 
virtual bool licensed (QString type)
 A licensing mechanism for node creation. More...
 
VFS_noderemoteNode ()
 Return the node needed to satisfy a remote request. More...
 

Additional Inherited Members

- Protected Member Functions inherited from VFS_node_interface
 VFS_node_interface (VFS_node *remoteNode=nullptr)
 VFS_node_interface::VFS_node_interface. More...
 
QString argumentString (QMetaObject s)
 Format a constructor string based on a node's metadata object. More...
 
- Protected Attributes inherited from VFS_node_interface
bool _remote
 Does this plugin exist on another resource? More...
 
VFS_node_remoteNode
 The node responding to requests for remote resources. More...
 

Detailed Description

Definition at line 6 of file VFS_pamPlugin.h.

Member Function Documentation

◆ arguments()

QString pamPlugin::arguments ( QString  type)
virtual

Describe the arguments needed to create a node.

Parameters
typeThe node name
Returns
The argument string.

The implementation of this pure method will look something like:

QString skeletonPlugin::arguments(QString type)
{
if (type == "skeleton")
return argumentString( skeleton::staticMetaObject );
}
QString argumentString(QMetaObject s)
Format a constructor string based on a node's metadata object.
virtual QString arguments(QString type)
Describe the arguments needed to create a node.
See also
The Skeleton Plugin

Reimplemented from VFS_node_interface.

Definition at line 22 of file VFS_pamPlugin.cpp.

◆ create()

VFS_node * pamPlugin::create ( QString  type,
QVariantMap  env,
QDomElement  child 
)
virtual

Create a new node instance.

Base implementation that does nothing.

Returns
The new VFS_node, or 0 (null) if it was unable to create it.

Plugins bundle groups of node definitions together. This is the factory function for creating new nodes.

For example:

VFS_node *myFancyPlugin::create(QString type, QVariantMap env, QDomElement child)
{
if (type == "myFancyNode")
{
int a = VFS_creator::configAttribute(env,child,"alpha").toInt();
QString b = VFS_creator::configAttribute(env,child,"beta",false,"beta string");
return new myFancyNode(a,b);
}
if (type == "myMagicNode")
{
QString magicPath = VFS_creator::configPathAttribute(env,child,"magicPath");
return new myMagicNode(magicPath);
}
return 0;
}
static QString configAttribute(QVariantMap env, QDomElement e, QString attr, bool req=true, QString def="")
Fetch an XML node attribute value and resolve it against an environment.
static QString configPathAttribute(QVariantMap env, QDomElement e, QString attr, bool req=true, QString def="")
Fetch an XML node attribute value and resolve it against an environment, ensuring it is a cleaned pat...
VFS_node is the base class from which all other VFS_node classes derive.
Definition: VFS_node.h:143

Please note the entries for a config file:

<myFancyNode name='fancy1' alpha='10' beta='gamma' />
<myMagicNode name='magic_thing' magicPath='/mnt/magic' />

As a pure virtual function, this must be implemented in all plugins.

See also
The Skeleton Plugin
Parameters
typeThe node type, as listed in provides() and referenced in a config.xml
envThe constructor environment
childThe config DOM element
Returns
Always returns a nullptr

Subclasses must implement this for a plugin to be useful. This base implementation is present so that a minimal plugin can implement initialize() without providing any nodes.

Reimplemented from VFS_node_interface.

Definition at line 39 of file VFS_pamPlugin.cpp.

◆ description()

QString pamPlugin::description ( QString  type)
virtual

Descriptive text about an individual node.

Parameters
typeThe node name
Returns
The description string.

The implementation of this pure method will look something like:

QString skeletonPlugin::description(QString type)
{
if (type == "skeleton")
return "A node provided as an example for the documentation. It does nothing.";
}
virtual QString description(QString type)
Descriptive text about an individual node.
See also
The Skeleton Plugin

Reimplemented from VFS_node_interface.

Definition at line 14 of file VFS_pamPlugin.cpp.

◆ initialize()

bool pamPlugin::initialize ( )
virtual

The plugin initializer.

Returns
bool The initialization status.

This is an opportunity to register filetypes, log data, or perform any other prep work needed.

For instance:

bool myFancyPlugin::initialize()
{
if (!VFS_node_type::registerType("magic","myFancyPlugin:magicNode",true))
{ VFS::WARN( "Could not register type 'magic'... is it already registered by something else?" );
return false;
}
if (!connectToLicenseServer("myFancyPlugin"))
{ VFS::WARN( "Could not connect to license server for 'myFancyPlugin'. License was denied." );
return false;
}
return true;
}
static bool registerType(QString type, QString handler, bool json=true)
Add a type to the registry.
static void WARN(QString message, int level=0, QString user="server")
Send a message to the VFS::_warnings VFS_stream.
Definition: VFS.cpp:258

If a plugin fails to initialize, it can return false here and will not be added to the plugin registry.

This may also be used to create a (network or other) license check for this node group so future licensed() requests don't have to do network validation. In practice nodes should be licensed per use, not globally when the application starts, and should be checked at some interval for validity.

Reimplemented from VFS_node_interface.

Definition at line 8 of file VFS_pamPlugin.cpp.

◆ provides()

QStringList pamPlugin::provides ( )
virtual

A string list of node names that this plugin is prepared to create.

Base implementation that returns an empty list.

Returns
The list of nodes

Plugins bundle groups of node definitions together. This is the list of nodes.

For example:

QStringList myFancyPlugin::provides()
{
QStringList p;
p << "myFancyNode";
p << "myMagicNode";
return p;
}

As a pure virtual function, this must be implemented in all plugins.

See also
The Skeleton Plugin
Returns
An empty list

Subclasses must implement this for a plugin to be useful. This base implementation is present so that a minimal plugin can implement initialize() without providing any nodes.

Reimplemented from VFS_node_interface.

Definition at line 30 of file VFS_pamPlugin.cpp.


The documentation for this class was generated from the following files: