Skip to content

Commit

Permalink
Move MythSystemPrivate out of public interface header.
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-kristjansson committed May 23, 2013
1 parent 2968f52 commit 2366b4d
Show file tree
Hide file tree
Showing 5 changed files with 87 additions and 62 deletions.
3 changes: 2 additions & 1 deletion mythtv/libs/libmythbase/libmythbase.pro
Expand Up @@ -17,7 +17,8 @@ HEADERS += verbosedefs.h mythversion.h compat.h mythconfig.h
HEADERS += mythobservable.h mythevent.h
HEADERS += mythtimer.h mythsignalingtimer.h mythdirs.h exitcodes.h
HEADERS += lcddevice.h mythstorage.h remotefile.h logging.h loggingserver.h
HEADERS += mythcorecontext.h mythsystem.h mythlocale.h storagegroup.h
HEADERS += mythcorecontext.h mythsystem.h mythsystemprivate.h
HEADERS += mythlocale.h storagegroup.h
HEADERS += mythcoreutil.h mythdownloadmanager.h mythtranslation.h
HEADERS += unzip.h unzip_p.h zipentry_p.h iso639.h iso3166.h mythmedia.h
HEADERS += mythmiscutil.h mythhdd.h mythcdrom.h autodeletedeque.h dbutil.h
Expand Down
63 changes: 2 additions & 61 deletions mythtv/libs/libmythbase/mythsystem.h
Expand Up @@ -56,9 +56,6 @@ typedef enum MythSystemMask {
#include <QBuffer>
#include <QSemaphore>
#include <QMap> // FIXME: This shouldn't be needed, Setting_t is not public
#include <QPointer> // FIXME: QPointer is deprecated

#include "referencecounter.h"

// FIXME: _t is not how we name types in MythTV...
typedef QMap<QString, bool> Setting_t;
Expand Down Expand Up @@ -185,11 +182,12 @@ class MBASE_PUBLIC MythSystem : public QObject

private:
void initializePrivate(void);
MythSystemPrivate *d;
MythSystemPrivate *d; // FIXME we generally call this m_priv in MythTV

protected:
void ProcessFlags(uint flags);

// FIXME if we already have a private helper, why all this?
uint m_status;
QSemaphore m_semReady;

Expand All @@ -205,63 +203,6 @@ class MBASE_PUBLIC MythSystem : public QObject
QBuffer m_stdbuff[3];
};

// FIXME: do we really need reference counting?
// it shouldn't be difficult to track the lifetime of a private object.
// FIXME: This should not live in the same header as MythSystem
class MythSystemPrivate : public QObject, public ReferenceCounter
{
Q_OBJECT

public:
MythSystemPrivate(const QString &debugName);

virtual void Fork(time_t timeout) = 0;
virtual void Manage(void) = 0;

virtual void Term(bool force=false) = 0;
virtual void Signal(int sig) = 0;
virtual void JumpAbort(void) = 0;

virtual bool ParseShell(const QString &cmd, QString &abscmd,
QStringList &args) = 0;

protected:
QPointer<MythSystem> m_parent;

uint GetStatus(void) { return m_parent->GetStatus(); }
void SetStatus(uint status) { m_parent->SetStatus(status); }

// FIXME: We should not return a reference here
QString& GetLogCmd(void) { return m_parent->GetLogCmd(); }
// FIXME: We should not return a reference here
QString& GetDirectory(void) { return m_parent->GetDirectory(); }

bool GetSetting(const char *setting)
{ return m_parent->GetSetting(setting); }

// FIXME: We should not return a reference here
QString& GetCommand(void) { return m_parent->GetCommand(); }
void SetCommand(QString &cmd) { m_parent->SetCommand(cmd); }

// FIXME: We should not return a reference here
// FIXME: Rename "GetArguments"
QStringList &GetArgs(void) { return m_parent->GetArgs(); }
// FIXME: Rename "SetArguments"
void SetArgs(QStringList &args) { m_parent->SetArgs(args); }

// FIXME: This is likely a bad idea, but possibly manageable
// since this is a private class.
QBuffer *GetBuffer(int index) { return m_parent->GetBuffer(index); }
// FIXME: This is likely a bad idea, but possibly manageable
// since this is a private class.
void Unlock(void) { m_parent->Unlock(); }

signals:
void started(void);
void finished(void);
void error(uint status);
void readDataReady(int fd);
};


MBASE_PUBLIC uint myth_system(const QString &command,
Expand Down
81 changes: 81 additions & 0 deletions mythtv/libs/libmythbase/mythsystemprivate.h
@@ -0,0 +1,81 @@
/// -*- Mode: c++ -*-

#ifndef MYTHSYSTEMPRIVATE_H_
#define MYTHSYSTEMPRIVATE_H_

// C header
#include <stdint.h> // for uint

// Qt header
#include <QPointer> // FIXME: QPointer is deprecated
#include <QObject>

// MythTV header
#include "referencecounter.h"
#include "mythbaseexp.h"
#include "mythsystem.h"

class QStringList;
class QString;
class QBuffer;

// FIXME: do we really need reference counting?
// it shouldn't be difficult to track the lifetime of a private object.
// FIXME: This should not live in the same header as MythSystem
class MythSystemPrivate : public QObject, public ReferenceCounter
{
Q_OBJECT

public:
MythSystemPrivate(const QString &debugName);

virtual void Fork(time_t timeout) = 0;
virtual void Manage(void) = 0;

virtual void Term(bool force=false) = 0;
virtual void Signal(int sig) = 0;
virtual void JumpAbort(void) = 0;

virtual bool ParseShell(const QString &cmd, QString &abscmd,
QStringList &args) = 0;

protected:
// FIXME: QPointer uses global hash & is deprecated for good reason
QPointer<MythSystem> m_parent;

uint GetStatus(void) { return m_parent->GetStatus(); }
void SetStatus(uint status) { m_parent->SetStatus(status); }

// FIXME: We should not return a reference here
QString& GetLogCmd(void) { return m_parent->GetLogCmd(); }
// FIXME: We should not return a reference here
QString& GetDirectory(void) { return m_parent->GetDirectory(); }

bool GetSetting(const char *setting)
{ return m_parent->GetSetting(setting); }

// FIXME: We should not return a reference here
QString& GetCommand(void) { return m_parent->GetCommand(); }
void SetCommand(QString &cmd) { m_parent->SetCommand(cmd); }

// FIXME: We should not return a reference here
// FIXME: Rename "GetArguments"
QStringList &GetArgs(void) { return m_parent->GetArgs(); }
// FIXME: Rename "SetArguments"
void SetArgs(QStringList &args) { m_parent->SetArgs(args); }

// FIXME: This is likely a bad idea, but possibly manageable
// since this is a private class.
QBuffer *GetBuffer(int index) { return m_parent->GetBuffer(index); }
// FIXME: This is likely a bad idea, but possibly manageable
// since this is a private class.
void Unlock(void) { m_parent->Unlock(); }

signals:
void started(void);
void finished(void);
void error(uint status);
void readDataReady(int fd);
};

#endif // MYTHSYSTEMPRIVATE_H_
1 change: 1 addition & 0 deletions mythtv/libs/libmythbase/mythsystemunix.h
Expand Up @@ -16,6 +16,7 @@
#include <QMutex>
#include <QPointer>

#include "mythsystemprivate.h"
#include "mythbaseexp.h"
#include "mythsystem.h"
#include "mthread.h"
Expand Down
1 change: 1 addition & 0 deletions mythtv/libs/libmythbase/mythsystemwindows.h
Expand Up @@ -12,6 +12,7 @@
#include <QList>
#include <QMap>

#include "mythsystemprivate.h"
#include "mythbaseexp.h"
#include "mythsystem.h"
#include "mthread.h"
Expand Down

0 comments on commit 2366b4d

Please sign in to comment.