Remoto - VFS: VFS_creator.h Source File
Remoto - VFS
VFS_creator.h
Go to the documentation of this file.
1 #ifndef VFS_CREATOR_H
2 #define VFS_CREATOR_H
3 
4 #include <QObject>
5 #include <QDomDocument>
6 #include <QSemaphore>
7 #include <QProcessEnvironment>
8 #include <QMap>
9 
10 #include "VFS.h"
11 #include "VFS_base/VFS_node.h"
13 #include "VFS_auth/VFS_session.h"
14 
15 #define VFS_CREATOR_MAX_OUTSTANDING 100 //maximum number of concurrent outstanding builds
16 
18 {
19  friend class VFS;
20  friend class VFS_thread;
21  friend class VFS_threadthread;
22 
23  public:
24  //explicit VFS_creator();
25  //~VFS_creator();
26 
27  static QString configAttribute(QVariantMap env, QDomElement e, QString attr, bool req=true, QString def="");
28  static QString configPathAttribute(QVariantMap env, QDomElement e, QString attr, bool req=true, QString def="");
29  static bool configBoolAttribute(QVariantMap env, QDomElement e, QString attr, bool req=true, bool def=false);
30  static int configIntAttribute(QVariantMap env, QDomElement e, QString attr, bool req=true, int def=0);
31  static double configDoubleAttribute(QVariantMap env, QDomElement e, QString attr, bool req=true, double def=0.0);
32  static QString resolveEnvValue(QString value, QVariantMap env);
33 
34  //static QString code(QString nodename, QString libname, QString &error);
35  static VFS_request *code(VFS_request *r);
36  static QJsonObject codeDirectory(QString &error);
37 
38  static bool registerPlugin(QString name, VFS_node_interface *node);
39  static bool unregisterPlugin(QString name);
40 
41  static QMutex _pluginsLock;
42 
43  private:
44  static void init(QStringList plugins=QStringList(), bool describe = false);
45 
46  static QVariantMap constructEnvironment(QVariantMap env, QDomElement c);
47  static void setParameters(QVariantMap env, QDomElement c);
48 
49  static void build(QString configFile, VFS_node *root, bool printConfig=false);
50  static void constructConfig(QString configFile, QVariantMap env, VFS_node *mount, bool printConfig, QDomNamedNodeMap attrs=QDomNamedNodeMap());
51  static void constructNodes(QDomElement nodeConfig, QVariantMap env, VFS_node *mount, bool printConfig=false);
52  static VFS_node *constructNode(QDomElement child, QVariantMap &env, bool printConfig=false);
53 
54  static QMap<QString, VFS_node_interface *> _plugins;
55 
56  static QSemaphore _outstanding;
57  static QProcessEnvironment _systemEnvironment;
58 };
59 
60 #endif // VFS_CREATOR_H
VFS_creator is a static class used to instantiate nodes.
Definition: VFS_creator.h:18
static VFS_node * constructNode(QDomElement child, QVariantMap &env, bool printConfig=false)
VFS_creator::constructNode.
static QJsonObject codeDirectory(QString &error)
Gather and return a directory of code namespaces served by this VFS instance.
static void build(QString configFile, VFS_node *root, bool printConfig=false)
Build an environment for creating nodes.
static bool registerPlugin(QString name, VFS_node_interface *node)
Register a plugin.
static int configIntAttribute(QVariantMap env, QDomElement e, QString attr, bool req=true, int def=0)
Fetch an XML node attribute value and resolve it against an environment, returning it as an int.
static void constructNodes(QDomElement nodeConfig, QVariantMap env, VFS_node *mount, bool printConfig=false)
Now that the file is open and an environment exists, do the work.
static bool configBoolAttribute(QVariantMap env, QDomElement e, QString attr, bool req=true, bool def=false)
Fetch an XML node attribute value and resolve it against an environment, returning it as a bool.
static VFS_request * code(VFS_request *r)
Resolve a request for code.
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 QMap< QString, VFS_node_interface * > _plugins
The plugin registry.
Definition: VFS_creator.h:54
static void init(QStringList plugins=QStringList(), bool describe=false)
Initialize plugins recursively.
Definition: VFS_creator.cpp:60
static bool unregisterPlugin(QString name)
Unregister a plugin.
static void constructConfig(QString configFile, QVariantMap env, VFS_node *mount, bool printConfig, QDomNamedNodeMap attrs=QDomNamedNodeMap())
Build nodes from a config file using the provided environment values.
static double configDoubleAttribute(QVariantMap env, QDomElement e, QString attr, bool req=true, double def=0.0)
Fetch an XML node attribute value and resolve it against an environment, returning it as a double val...
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...
static QMutex _pluginsLock
A mutex for protecting the _plugins object.
Definition: VFS_creator.h:41
static QVariantMap constructEnvironment(QVariantMap env, QDomElement c)
Construct an environment from an <env> node.
static QString resolveEnvValue(QString value, QVariantMap env)
Resolve an incoming value against the system environment and the provided environment.
static QProcessEnvironment _systemEnvironment
The system environment inherited during startup.
Definition: VFS_creator.h:57
static void setParameters(QVariantMap env, QDomElement c)
Set parameters on the VFS::root() instance, for future query.
static QSemaphore _outstanding
A semaphore used to sync creation during startup.
Definition: VFS_creator.h:56
The interface class for dynamically loaded plugins.
VFS_node is the base class from which all other VFS_node classes derive.
Definition: VFS_node.h:143
The base class for all requests between nodes.
Definition: VFS_node.h:54
A thread interface for creating multithreaded applications.
Definition: VFS_thread.h:32
A subclass of QThread, which provides an event loop in a different thread.
Definition: VFS_thread.h:11
VFS is the root node for a Virtual Filesystem.
Definition: VFS.h:15