Fotobot
Get data from your photovoltaic plant
Static Public Member Functions | Static Public Attributes | Static Private Attributes | List of all members
Static Class Reference

#include <static.h>

Static Public Member Functions

static QString getConfigFileName ()
 
static QString getConfigDir ()
 

Static Public Attributes

static TemplateLoader * templateLoader =0
 
static HttpSessionStore * sessionStore =0
 
static StaticFileController * staticFileController =0
 
static DATABASEdb = 0
 
static INVERTORSinvertors = 0
 
static INTERFACEBOXinterfacebox = 0
 
static SLUNCEslunce = 0
 

Static Private Attributes

static QString configDir =0
 

Detailed Description

This class contains some static resources that are used by the application.

Definition at line 23 of file static.h.

Member Function Documentation

QString Static::getConfigDir ( )
static

Gets the directory where the main config file is located. On the first call, the INI file gets searched. If not found, the application aborts with an error message.

See also
getConfigFileName()

Definition at line 33 of file static.cpp.

33  {
34  if (!configDir.isNull()) {
35  return configDir;
36  }
37  // Search config file
38 
39  QString binDir=QCoreApplication::applicationDirPath();
40  QString organization=QCoreApplication::organizationName();
41  QString configFileName=QCoreApplication::applicationName()+".ini";
42 
43  QStringList searchList;
44  searchList.append(QDir::cleanPath(binDir));
45  searchList.append(QDir::cleanPath(binDir+"/../etc"));
46  searchList.append(QDir::cleanPath(binDir+"/../../etc")); // for development under windows
47  searchList.append(QDir::rootPath()+"etc/xdg/"+organization);
48  searchList.append(QDir::rootPath()+"etc/opt");
49  searchList.append(QDir::rootPath()+"etc");
50 
51  foreach (QString dir, searchList) {
52  QFile file(dir+"/"+configFileName);
53  if (file.exists()) {
54  // found
55  configDir=dir;
56  qDebug("Using config file %s",qPrintable(file.fileName()));
57  return configDir;
58  }
59  }
60 
61  // not found
62  foreach (QString dir, searchList) {
63  qWarning("%s/%s not found",qPrintable(dir),qPrintable(configFileName));
64  }
65  qFatal("Cannot find config file %s",qPrintable(configFileName));
66  return 0;
67 }
static QString configDir
Definition: static.h:73
QString Static::getConfigFileName ( )
static

Search the main config file and return its full path. On the first call, the INI file gets searched. If not found, the application aborts with an error message.

The filename is the applications name plus the ending ".ini". It is searched in the following directories:

  • Same directory as the applications executable file
  • In ../etc relative to the applications executable file
  • In ../../etc relative to the applications executable file
  • In /etc/xdg/{organisation name} on the root drive
  • In /etc/opt on the root drive
  • In /etc on the root drive

Definition at line 29 of file static.cpp.

29  {
30  return QString("%1/%2.ini").arg(getConfigDir()).arg(QCoreApplication::applicationName());
31 }
static QString getConfigDir()
Definition: static.cpp:33

Member Data Documentation

QString Static::configDir =0
staticprivate

Directory of the main config file

Definition at line 73 of file static.h.

HttpSessionStore * Static::sessionStore =0
static

Storage for session cookies

Definition at line 57 of file static.h.

StaticFileController * Static::staticFileController =0
static

Controller for static files

Definition at line 60 of file static.h.

TemplateLoader * Static::templateLoader =0
static

Cache for template files

Definition at line 54 of file static.h.


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