Just Intonation  Version 1.3.1 (19)
Explore key-independent dynamically adapting tuning in just intonation
platformtools.h
Go to the documentation of this file.
1 /*****************************************************************************
2  * Copyright 2016-2017 Karolin Stange, Christoph Wick, and Haye Hinrichsen
3  *
4  * This file is part of JustIntonation.
5  *
6  * JustIntonation is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * JustIntonation is distributed in the hope that it will be useful, but
12  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
13  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14  * for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with JustIntonation. If not, see http://www.gnu.org/licenses/.
18  *****************************************************************************/
19 
20 #ifndef PLATFORMTOOLS_H
21 #define PLATFORMTOOLS_H
22 
23 #include <memory>
24 #include <assert.h>
25 
26 #include <QStorageInfo>
27 
28 class Application;
29 
39 
41 {
42 protected:
44 
45 public:
46 
55 
57  {
58  assert(getPointerToInstance());
59  return *getPointerToInstance();
60  }
61 
65 
66  virtual void init (Application &application) {(void)application;}
67 
68 
72 
73  virtual void disableScreensaver() {}
74 
75 
79 
80  virtual void enableScreensaver() {}
81 
82 
83  //-------------------------------------------------------------------------
84  // Determine free disk space
85  //-------------------------------------------------------------------------
92 
93  virtual qint64 getFreeDiskSpace(const QString &path)
94  {
95  return QStorageInfo(path).bytesTotal();
96  }
97 
98 
99 //=================================================================================
100 
101 public:
102 
106 
107  static std::unique_ptr<PlatformTools> &getPointerToInstance()
108  {
109  static std::unique_ptr<PlatformTools> mInstance(new PlatformTools);
110  return mInstance;
111  }
112 };
113 
117 
118 template <class T>
120 public:
121  friend class PlatformTools;
123  {
124  PlatformTools::getPointerToInstance().reset(new T());
125  }
126 };
127 
128 #endif // PLATFORMTOOLS_H
virtual void init(Application &application)
Platform-dependent initialization.
Definition: platformtools.h:66
static PlatformTools & getSingleton()
Definition: platformtools.h:56
virtual qint64 getFreeDiskSpace(const QString &path)
Determine free disk space.
Definition: platformtools.h:93
virtual void enableScreensaver()
Function to enable the screen saver.
Definition: platformtools.h:80
virtual void disableScreensaver()
Function to disable the screen saver.
Definition: platformtools.h:73
Main application.
Definition: application.h:60
Base class providing support for various platforms.
Definition: platformtools.h:40
Helper class for instantiating objects derived from PlatformTools.
static std::unique_ptr< PlatformTools > & getPointerToInstance()
Function holding the instance pointer as a static unique pointer.