Remoto - VFS: VFS.h Source File
Remoto - VFS
VFS.h
Go to the documentation of this file.
1 
2 #ifndef VFS_H
3 #define VFS_H
4 
5 #include <QDateTime>
6 #include <QTimerEvent>
7 
8 #include "VFS_base/VFS_node.h"
9 
10 #include "utilities/colorPrint.h"
11 
12 class VFS_thread;
13 
14 class VFS : public VFS_node
15 {
16  Q_OBJECT
17 
18  friend class VFS_creator; //to set _logLevel, _logTime, _adminEmail
19 
20  public:
21  VFS(QString configFile, QStringList plugins=QStringList(), bool describe=false, bool printConfig=false);
22  ~VFS();
23 
24  static void LOG(QString message, int level=0, QString user="server");
25  static void WARN(QString message, int level=0, QString user="server");
26  static void ERROR(QString message, int level=0, QString user="server");
27  static void CRITICAL(QString message);
28 
29  static VFS* root();
30  static QJsonDocument parameters();
31  static qint64 starttime();
32  static qint64 uptime();
33  static QString uptimeString(bool ms=true);
34 
35  void getLogSettings(int &loglevel, int &logtime);
36 
37  protected:
38  static VFS *_vfs;
39  static QJsonObject _parameters;
40 
41  virtual QByteArray icon();
42 
43  private:
44  qint64 _start;
45 
46  ColorPrint cp_init;
47  ColorPrint cp_bold;
48  ColorPrint cp_warn;
49  ColorPrint cp_error;
50 
51  int _logLevel;
52  int _logTime;
54 
55  mutable QMutex _printLock;
56 
57  static QMap<QString,QDateTime> _monitoredFiles;
59  void monitoredFilesCheck();
60 
61  void setAdminEmail(QString emails);
62  void setLogSettings(int loglevel,int logtime);
63 
64  void timerEvent(QTimerEvent *event);
65 
66  signals:
67  void initialized();
69 
70  protected slots:
71  //virtual void applyDiff(VFS_request *t);
72 };
73 
74 #endif //VFS_H
75 
VFS_creator is a static class used to instantiate nodes.
Definition: VFS_creator.h:18
VFS_node is the base class from which all other VFS_node classes derive.
Definition: VFS_node.h:143
A thread interface for creating multithreaded applications.
Definition: VFS_thread.h:32
VFS is the root node for a Virtual Filesystem.
Definition: VFS.h:15
static QJsonObject _parameters
VFS parameters, defined in a config file.
Definition: VFS.h:39
ColorPrint cp_bold
Color settings for bold printing.
Definition: VFS.h:47
void timerEvent(QTimerEvent *event)
Timer handler for VFS timer events.
Definition: VFS.cpp:468
static QMap< QString, QDateTime > _monitoredFiles
A list of path:datetime entries that the VFS will monitor for changes.
Definition: VFS.h:57
static VFS * root()
Return the root node of the VFS filesystem.
Definition: VFS.cpp:399
int _logLevel
Filter log entries by this value... lower entries are very important, higher ones are more fine-grain...
Definition: VFS.h:51
void setLogSettings(int loglevel, int logtime)
Set the loglevel and logtime values for the logger.
Definition: VFS.cpp:163
static void LOG(QString message, int level=0, QString user="server")
Send a message to the VFS::_messages VFS_stream.
Definition: VFS.cpp:209
void codeDirectoryUpdated()
Emitted when VFS_creator has had its _plugins updated. This is for VFS_tcp_mount and VFS_tcp_export.
void setAdminEmail(QString emails)
Set the admin email addresses for CRITICAL messages.
Definition: VFS.cpp:148
static void ERROR(QString message, int level=0, QString user="server")
Send a message to the VFS::_errors VFS_stream.
Definition: VFS.cpp:307
static void CRITICAL(QString message)
Send a message to the VFS::_critical VFS_stream.
Definition: VFS.cpp:357
int _logTime
Include log entry time in output, where 0 = none, 1 = locale time, 2 = locale time and date,...
Definition: VFS.h:52
void initialized()
Emitted when the VFS_creator has completed its VFS_creator::build() call.
static QString uptimeString(bool ms=true)
Get the uptime of this VFS instance as a string.
Definition: VFS.cpp:443
int _monitorTimerID
The timerID for monitoring config file changes.
Definition: VFS.h:58
ColorPrint cp_init
Color settings to print messages when other streams do not exist.
Definition: VFS.h:46
static void WARN(QString message, int level=0, QString user="server")
Send a message to the VFS::_warnings VFS_stream.
Definition: VFS.cpp:258
VFS(QString configFile, QStringList plugins=QStringList(), bool describe=false, bool printConfig=false)
The VFS constructor will create a VFS based on an incoming config file and list of plugins.
Definition: VFS.cpp:50
void getLogSettings(int &loglevel, int &logtime)
Get the loglevel and logtime values for the logger.
Definition: VFS.cpp:182
void monitoredFilesCheck()
Iterate through all monitored files, and check their modification time.
Definition: VFS.cpp:485
qint64 _start
Set when the VFS instance begins. This is used to track uptime.
Definition: VFS.h:44
static qint64 starttime()
Get the epoch start time of this VFS instance, in milliseconds.
Definition: VFS.cpp:422
static qint64 uptime()
Get the uptime of this VFS instance, in milliseconds.
Definition: VFS.cpp:432
virtual QByteArray icon()
Fetch the icon for this node.
Definition: VFS.cpp:193
ColorPrint cp_error
Color settings for error messages.
Definition: VFS.h:49
static QJsonDocument parameters()
Fetch the parameters assigned to this VFS, as per the config file.
Definition: VFS.cpp:412
ColorPrint cp_warn
Color settings for warning messages.
Definition: VFS.h:48
VFS_thread * _logger
The VFS_logger instance, which will always be on another thread.
Definition: VFS.h:53
~VFS()
Destroy the VFS node, which will remove references to logging nodes and return output to cp_init colo...
Definition: VFS.cpp:132
QMutex _printLock
A lock for ensuring that print messags don't get interleaved.
Definition: VFS.h:55
static VFS * _vfs
The global and single instance of VFS, returned by VFS::root()
Definition: VFS.h:38