mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-31 12:55:33 +08:00
refs #199 , context base class to simplify handling
* usingLocalObjects() now derived from runtime config, no need to override it in contexts * getRuntime in base class, no longer to implement it in each context class
This commit is contained in:
49
src/blackcore/context.h
Normal file
49
src/blackcore/context.h
Normal file
@@ -0,0 +1,49 @@
|
||||
#ifndef BLACKCORE_CONTEXT_H
|
||||
#define BLACKCORE_CONTEXT_H
|
||||
|
||||
#include <QObject>
|
||||
#include "blackcore/context_runtime_config.h"
|
||||
#include "blackcore/context_runtime.h"
|
||||
|
||||
namespace BlackCore
|
||||
{
|
||||
/*!
|
||||
* \brief Base for all context classes
|
||||
*/
|
||||
class CContext : public QObject
|
||||
{
|
||||
private:
|
||||
CRuntimeConfig::ContextMode m_mode;
|
||||
|
||||
public:
|
||||
//! Destructor
|
||||
~CContext() {}
|
||||
|
||||
//! Using local objects?
|
||||
bool usingLocalObjects() const
|
||||
{
|
||||
return m_mode == CRuntimeConfig::Local || m_mode == CRuntimeConfig::LocalInDbusServer;
|
||||
}
|
||||
|
||||
//! Runtime
|
||||
CRuntime *getRuntime()
|
||||
{
|
||||
Q_ASSERT(this->parent());
|
||||
return static_cast<CRuntime *>(this->parent());
|
||||
}
|
||||
|
||||
//! Const runtime
|
||||
const CRuntime *getRuntime() const
|
||||
{
|
||||
Q_ASSERT(this->parent());
|
||||
return static_cast<CRuntime *>(this->parent());
|
||||
}
|
||||
|
||||
protected:
|
||||
//! Constructor
|
||||
CContext(CRuntimeConfig::ContextMode mode, QObject *parent) : QObject(parent), m_mode(mode)
|
||||
{}
|
||||
|
||||
};
|
||||
}
|
||||
#endif // guard
|
||||
Reference in New Issue
Block a user