refactoring, stage 1: turned GLiveSupport into a Singleton
This commit is contained in:
parent
c7e0c451be
commit
7da892d146
4 changed files with 102 additions and 67 deletions
|
@ -85,8 +85,15 @@ using namespace LiveSupport::GLiveSupport;
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* The name of the config element for this class
|
* The name of the config element for this class
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
const std::string LiveSupport :: GLiveSupport ::
|
const std::string
|
||||||
GLiveSupport :: configElementNameStr = "gLiveSupport";
|
LiveSupport :: GLiveSupport :: GLiveSupport :: configElementNameStr
|
||||||
|
= "gLiveSupport";
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* The singleton instance of GLiveSupport
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
Ptr<LiveSupport::GLiveSupport::GLiveSupport>::Ref
|
||||||
|
LiveSupport :: GLiveSupport :: GLiveSupport :: singleton;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
@ -209,6 +216,21 @@ const std::string serialPortDefaultDevice = "/dev/ttyS0";
|
||||||
|
|
||||||
/* ============================================================= module code */
|
/* ============================================================= module code */
|
||||||
|
|
||||||
|
/*------------------------------------------------------------------------------
|
||||||
|
* Return the singleton instance to WidgetFactory
|
||||||
|
*----------------------------------------------------------------------------*/
|
||||||
|
Ptr<LiveSupport::GLiveSupport::GLiveSupport>::Ref
|
||||||
|
LiveSupport :: GLiveSupport ::
|
||||||
|
GLiveSupport :: getInstance(void) throw ()
|
||||||
|
{
|
||||||
|
if (!singleton.get()) {
|
||||||
|
singleton.reset(new LiveSupport::GLiveSupport::GLiveSupport());
|
||||||
|
}
|
||||||
|
|
||||||
|
return singleton;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
* Configure the gLiveSupport object
|
* Configure the gLiveSupport object
|
||||||
*----------------------------------------------------------------------------*/
|
*----------------------------------------------------------------------------*/
|
||||||
|
|
|
@ -155,6 +155,11 @@ class GLiveSupport : public LocalizedConfigurable,
|
||||||
*/
|
*/
|
||||||
static const std::string configElementNameStr;
|
static const std::string configElementNameStr;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The singleton instance of this object.
|
||||||
|
*/
|
||||||
|
static Ptr<GLiveSupport>::Ref singleton;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The authentication client used by the application.
|
* The authentication client used by the application.
|
||||||
*/
|
*/
|
||||||
|
@ -357,6 +362,18 @@ class GLiveSupport : public LocalizedConfigurable,
|
||||||
*/
|
*/
|
||||||
bool schedulerAvailable;
|
bool schedulerAvailable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Private constructor.
|
||||||
|
*/
|
||||||
|
GLiveSupport(void) throw ()
|
||||||
|
: outputPlayerIsPaused(false),
|
||||||
|
cuePlayerIsPaused(false)
|
||||||
|
{
|
||||||
|
openedAudioClips.reset(new AudioClipMap());
|
||||||
|
openedPlaylists.reset(new PlaylistMap());
|
||||||
|
serialStream.reset(new LibSerial::SerialStream());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display a message that the authentication server is not available.
|
* Display a message that the authentication server is not available.
|
||||||
* And offer a chance to edit the options to fix it.
|
* And offer a chance to edit the options to fix it.
|
||||||
|
@ -444,18 +461,6 @@ class GLiveSupport : public LocalizedConfigurable,
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*/
|
|
||||||
GLiveSupport(void) throw ()
|
|
||||||
: outputPlayerIsPaused(false),
|
|
||||||
cuePlayerIsPaused(false)
|
|
||||||
{
|
|
||||||
openedAudioClips.reset(new AudioClipMap());
|
|
||||||
openedPlaylists.reset(new PlaylistMap());
|
|
||||||
serialStream.reset(new LibSerial::SerialStream());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Virtual destructor.
|
* Virtual destructor.
|
||||||
*/
|
*/
|
||||||
|
@ -490,6 +495,14 @@ class GLiveSupport : public LocalizedConfigurable,
|
||||||
return configElementNameStr;
|
return configElementNameStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the singleton instance of this object.
|
||||||
|
*
|
||||||
|
* @return the singleton instance of this object.
|
||||||
|
*/
|
||||||
|
static Ptr<GLiveSupport>::Ref
|
||||||
|
getInstance() throw ();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure the scheduler daemon based on the XML element
|
* Configure the scheduler daemon based on the XML element
|
||||||
* supplied.
|
* supplied.
|
||||||
|
|
|
@ -113,7 +113,7 @@ GLiveSupportTest :: setUp(void) throw (CPPUNIT_NS::Exception)
|
||||||
{
|
{
|
||||||
Gtk::Main kit(0, 0);
|
Gtk::Main kit(0, 0);
|
||||||
|
|
||||||
gLiveSupport.reset(new GLiveSupport());
|
gLiveSupport = GLiveSupport::getInstance();
|
||||||
|
|
||||||
uid_t uid = getuid();
|
uid_t uid = getuid();
|
||||||
struct passwd * pwd = getpwuid(uid);
|
struct passwd * pwd = getpwuid(uid);
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
------------------------------------------------------------------------------*/
|
------------------------------------------------------------------------------*/
|
||||||
|
|
||||||
/** @file
|
/** @file
|
||||||
* This file contains the main entry point to the Scheduler daemon.
|
* This file contains the main entry point to the Studio client.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* ============================================================ include files */
|
/* ============================================================ include files */
|
||||||
|
@ -155,7 +155,7 @@ int main ( int argc,
|
||||||
}
|
}
|
||||||
|
|
||||||
Ptr<LiveSupport::GLiveSupport::GLiveSupport>::Ref
|
Ptr<LiveSupport::GLiveSupport::GLiveSupport>::Ref
|
||||||
gLiveSupport(new LiveSupport::GLiveSupport::GLiveSupport());
|
gLiveSupport = LiveSupport::GLiveSupport::GLiveSupport::getInstance();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
std::auto_ptr<xmlpp::DomParser>
|
std::auto_ptr<xmlpp::DomParser>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue