diff --git a/src/blackcore/context.h b/src/blackcore/context.h new file mode 100644 index 000000000..c94e68a3e --- /dev/null +++ b/src/blackcore/context.h @@ -0,0 +1,49 @@ +#ifndef BLACKCORE_CONTEXT_H +#define BLACKCORE_CONTEXT_H + +#include +#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(this->parent()); + } + + //! Const runtime + const CRuntime *getRuntime() const + { + Q_ASSERT(this->parent()); + return static_cast(this->parent()); + } + + protected: + //! Constructor + CContext(CRuntimeConfig::ContextMode mode, QObject *parent) : QObject(parent), m_mode(mode) + {} + + }; +} +#endif // guard