WIP (unfinished, doesn't compile) flesh out some impl details
This commit is contained in:
parent
29b9887faa
commit
60d41ea017
4 changed files with 252 additions and 60 deletions
|
|
@ -171,7 +171,7 @@ namespace gui {
|
|||
|
||||
NotificationService::NotificationService ()
|
||||
: implInstance_(this,_instance),
|
||||
serviceInstance_( LUMIERA_INTERFACE_REF (lumieraorg_GuiNotification, 1,lumieraorg_GuiNotificationFacade))
|
||||
serviceInstance_( LUMIERA_INTERFACE_REF (lumieraorg_GuiNotification, 0,lumieraorg_GuiNotificationFacade))
|
||||
{
|
||||
INFO (operate, "GuiNotification Facade opened.");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,12 +38,12 @@ typedef lumiera_playprocess* LumieraPlayProcess;
|
|||
#include "common/subsys.hpp"
|
||||
#include "include/interfaceproxy.hpp"
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
|
||||
|
||||
|
||||
namespace proc {
|
||||
|
||||
class PlayProcess;
|
||||
|
||||
|
||||
|
||||
/******************************************************************
|
||||
|
|
@ -68,31 +68,34 @@ namespace proc {
|
|||
static lumiera::facade::Accessor<DummyPlayer> facade;
|
||||
|
||||
|
||||
/**
|
||||
* Continuous playback process, which has been started with a specific
|
||||
* output size, format and framerate. It is a handle to a calculation process,
|
||||
* which is about to produce a stream of frames to be retrieved by calling
|
||||
* the #getFrame function on this handle.
|
||||
*
|
||||
* @todo solve the lifecycle and ownership!
|
||||
*/
|
||||
class Process
|
||||
: public LumieraPlayProcess,
|
||||
boost::noncopyable
|
||||
{
|
||||
public:
|
||||
virtual void pause(bool) =0;
|
||||
virtual void* const getFrame() =0;
|
||||
|
||||
virtual ~Process();
|
||||
};
|
||||
|
||||
|
||||
//////////////////TODO: define some dummy negotiation about size and framerate....
|
||||
|
||||
virtual PlayProcess& start() =0;
|
||||
virtual Process& start() =0;
|
||||
|
||||
virtual ~DummyPlayer();
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Continuous playback process, which has been started with a specific
|
||||
* output size, format and framerate. It is a handle to a calculation process,
|
||||
* which is about to produce a stream of frames to be retrieved by calling
|
||||
* the #getFrame function on this handle.
|
||||
*
|
||||
* @todo solve the lifecycle and ownership!
|
||||
*/
|
||||
class PlayProcess
|
||||
: public LumieraPlayProcess
|
||||
{
|
||||
public:
|
||||
virtual void pause(bool) =0;
|
||||
virtual void* const getFrame() =0;
|
||||
|
||||
virtual ~PlayProcess();
|
||||
};
|
||||
|
||||
|
||||
} // namespace proc
|
||||
|
|
@ -100,9 +103,9 @@ namespace proc {
|
|||
|
||||
|
||||
extern "C" {
|
||||
#endif /* =========================== CL Interface ===================== */
|
||||
#endif /* =========================== CL Interface ===================== */
|
||||
|
||||
|
||||
|
||||
#include "common/interface.h"
|
||||
|
||||
LUMIERA_INTERFACE_DECLARE (lumieraorg_DummyPlayer, 0
|
||||
|
|
|
|||
|
|
@ -25,49 +25,227 @@
|
|||
#include "lib/singleton.hpp"
|
||||
|
||||
#include <string>
|
||||
#include <boost/scoped_ptr.hpp>
|
||||
|
||||
|
||||
namespace proc {
|
||||
|
||||
using std::string;
|
||||
using lumiera::Subsys;
|
||||
using boost::scoped_ptr;
|
||||
|
||||
class DummyPlayerSubsysDescriptor
|
||||
: public Subsys
|
||||
{
|
||||
operator string () const { return "Engine"; }
|
||||
|
||||
bool
|
||||
shouldStart (lumiera::Option&)
|
||||
{
|
||||
TODO ("determine, if renderengine should be started");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
start (lumiera::Option&, Subsys::SigTerm termination)
|
||||
{
|
||||
UNIMPLEMENTED ("pull up renderengine and register shutdown hook");
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
triggerShutdown () throw()
|
||||
{
|
||||
UNIMPLEMENTED ("initiate halting the engine");
|
||||
}
|
||||
|
||||
bool
|
||||
checkRunningState () throw()
|
||||
{
|
||||
//Lock guard (*this);
|
||||
TODO ("implement detecting running state");
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
namespace {
|
||||
namespace { // hidden local details of the service implementation....
|
||||
|
||||
class DummyPlayerSubsysDescriptor
|
||||
: public Subsys
|
||||
{
|
||||
operator string () const { return "Dummy-Player"; }
|
||||
|
||||
bool
|
||||
shouldStart (lumiera::Option&)
|
||||
{
|
||||
return false; // for now the DummyPlayerService only comes "up" as dependency,
|
||||
} // but doesn't start as a subsystem on it's own.
|
||||
|
||||
bool
|
||||
start (lumiera::Option&, Subsys::SigTerm terminationHandle)
|
||||
{
|
||||
ASSERT (!thePlayer_);
|
||||
|
||||
thePlayer_.reset (new DummyPlayerService (terminationHandle));
|
||||
return true;
|
||||
}
|
||||
|
||||
/** manages the actual (single) instance of the player service impl */
|
||||
scoped_ptr<DummyPlayerService> thePlayer_;
|
||||
|
||||
|
||||
void
|
||||
triggerShutdown () throw()
|
||||
{
|
||||
TODO ("implement waiting for any playback processes to terminate gracefully");
|
||||
//..... but this would require us to use a separate thread, so I skip it for now.
|
||||
// Probably it's better design to mange the processes in a separate thread anyway...
|
||||
|
||||
thePlayer_.reset(0);
|
||||
}
|
||||
|
||||
bool
|
||||
checkRunningState () throw()
|
||||
{
|
||||
//note: not locking here...
|
||||
return (thePlayer_);
|
||||
}
|
||||
};
|
||||
|
||||
lumiera::Singleton<DummyPlayerSubsysDescriptor> theDescriptor;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/* ================== define an lumieraorg_GuiNotification instance ======================= */
|
||||
|
||||
LUMIERA_INTERFACE_INSTANCE (lumieraorg_interfacedescriptor, 0
|
||||
,lumieraorg_DummyPlayerFacade_descriptor
|
||||
, NULL, NULL, NULL
|
||||
, LUMIERA_INTERFACE_INLINE (name, LUIDGEN,
|
||||
const char*, (LumieraInterface ifa),
|
||||
{ (void)ifa; return "DummyPlayer"; }
|
||||
)
|
||||
, LUMIERA_INTERFACE_INLINE (brief, LUIDGEN,
|
||||
const char*, (LumieraInterface ifa),
|
||||
{ (void)ifa; return "Proc Interface: dummy player to test integration with the GUI"; }
|
||||
)
|
||||
, LUMIERA_INTERFACE_INLINE (homepage, LUIDGEN,
|
||||
const char*, (LumieraInterface ifa),
|
||||
{ (void)ifa; return "http://www.lumiera.org/develompent.html" ;}
|
||||
)
|
||||
, LUMIERA_INTERFACE_INLINE (version, LUIDGEN,
|
||||
const char*, (LumieraInterface ifa),
|
||||
{ (void)ifa; return "0.1~pre"; }
|
||||
)
|
||||
, LUMIERA_INTERFACE_INLINE (author, LUIDGEN,
|
||||
const char*, (LumieraInterface ifa),
|
||||
{ (void)ifa; return "Hermann Vosseler"; }
|
||||
)
|
||||
, LUMIERA_INTERFACE_INLINE (email, LUIDGEN,
|
||||
const char*, (LumieraInterface ifa),
|
||||
{ (void)ifa; return "Ichthyostega@web.de"; }
|
||||
)
|
||||
, LUMIERA_INTERFACE_INLINE (copyright, LUIDGEN,
|
||||
const char*, (LumieraInterface ifa),
|
||||
{
|
||||
(void)ifa;
|
||||
return
|
||||
"Copyright (C) Lumiera.org\n"
|
||||
" 2009 Hermann Vosseler <Ichthyostega@web.de>";
|
||||
}
|
||||
)
|
||||
, LUMIERA_INTERFACE_INLINE (license, LUIDGEN,
|
||||
const char*, (LumieraInterface ifa),
|
||||
{
|
||||
(void)ifa;
|
||||
return
|
||||
"This program is free software; you can redistribute it and/or modify\n"
|
||||
"it under the terms of the GNU General Public License as published by\n"
|
||||
"the Free Software Foundation; either version 2 of the License, or\n"
|
||||
"(at your option) any later version.\n"
|
||||
"\n"
|
||||
"This program is distributed in the hope that it will be useful,\n"
|
||||
"but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
|
||||
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
|
||||
"GNU General Public License for more details.\n"
|
||||
"\n"
|
||||
"You should have received a copy of the GNU General Public License\n"
|
||||
"along with this program; if not, write to the Free Software\n"
|
||||
"Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA";
|
||||
}
|
||||
)
|
||||
, LUMIERA_INTERFACE_INLINE (state, LUIDGEN,
|
||||
int, (LumieraInterface ifa),
|
||||
{(void)ifa; return LUMIERA_INTERFACE_EXPERIMENTAL; }
|
||||
)
|
||||
, LUMIERA_INTERFACE_INLINE (versioncmp, LUIDGEN,
|
||||
int, (const char* a, const char* b),
|
||||
{return 0;} ////////////////////////////////////////////TODO define version ordering
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
using lumiera::facade::LUMIERA_ERROR_FACADE_LIFECYCLE;
|
||||
typedef lib::SingletonRef<GuiNotification>::Accessor InstanceRef;
|
||||
|
||||
InstanceRef _instance; ///< a backdoor for the C Language impl to access the actual GuiNotification implementation...
|
||||
|
||||
typedef DummyPlayer::Process* ProcP;
|
||||
|
||||
|
||||
LUMIERA_INTERFACE_INSTANCE (lumieraorg_DummyPlayer, 0
|
||||
,lumieraorg_DummyPlayerFacade
|
||||
, LUMIERA_INTERFACE_REF(lumieraorg_interfacedescriptor, 0, lumieraorg_DummyPlayerFacade_descriptor)
|
||||
, NULL /* on open */
|
||||
, NULL /* on close */
|
||||
, LUMIERA_INTERFACE_INLINE (startPlay, LUIDGEN,
|
||||
LumieraPlayProcess, (void),
|
||||
{
|
||||
if (!_instance)
|
||||
{
|
||||
lumiera_error_set(LUMIERA_ERROR_FACADE_LIFECYCLE, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return static_cast<LumieraPlayProcess> (& (_instance->start()));
|
||||
}
|
||||
)
|
||||
, LUMIERA_INTERFACE_INLINE (pausePlay, LUIDGEN,
|
||||
void, (LumieraPlayProcess handle, bool doPlay),
|
||||
{
|
||||
if (!_instance)
|
||||
{
|
||||
lumiera_error_set(LUMIERA_ERROR_FACADE_LIFECYCLE, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
REQUIRE (handle);
|
||||
ProcP proc = dynamic_cast<ProcP> (handle);
|
||||
ASSERT (proc);
|
||||
|
||||
proc->pause(doPlay);
|
||||
}
|
||||
)
|
||||
, LUMIERA_INTERFACE_INLINE (terminate, LUIDGEN,
|
||||
void, (LumieraPlayProcess handle),
|
||||
{
|
||||
if (!_instance)
|
||||
{
|
||||
lumiera_error_set(LUMIERA_ERROR_FACADE_LIFECYCLE, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
REQUIRE (handle);
|
||||
ProcP proc = dynamic_cast<ProcP> (handle);
|
||||
ASSERT (proc);
|
||||
|
||||
UNIMPLEMENTED ("terminate a running playback process");
|
||||
}
|
||||
)
|
||||
, LUMIERA_INTERFACE_INLINE (getFrame, LUIDGEN,
|
||||
void *, (LumieraPlayProcess handle),
|
||||
{
|
||||
if (!_instance)
|
||||
{
|
||||
lumiera_error_set(LUMIERA_ERROR_FACADE_LIFECYCLE, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
REQUIRE (handle);
|
||||
ProcP proc = dynamic_cast<ProcP> (handle);
|
||||
ASSERT (proc);
|
||||
|
||||
return const_cast<void*> (proc->getFrame());
|
||||
}
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
|
||||
|
||||
} // (End) hidden service impl details
|
||||
|
||||
|
||||
|
||||
|
||||
DummyPlayerService::DummyPlayerService (Subsys::SigTerm terminationHandle)
|
||||
: notifyTermination_(terminationHandle)
|
||||
, implInstance_(this,_instance)
|
||||
, serviceInstance_( LUMIERA_INTERFACE_REF (lumieraorg_DummyPlayer, 0, lumieraorg_DummyPlayerFacade))
|
||||
{
|
||||
INFO (operate, "GuiNotification Facade opened.");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -68,8 +68,17 @@ namespace proc {
|
|||
|
||||
/* === Implementation of the Facade Interface === */
|
||||
|
||||
void displayInfo (string const& text);
|
||||
void triggerGuiShutdown (string const& cause);
|
||||
Process& start();
|
||||
|
||||
|
||||
/** for now we use an single inline Process...
|
||||
* @todo actually implement multiple independent Playback processes!
|
||||
* @todo I am aware holding this object inline may cause a segfault at shutdown!
|
||||
*/
|
||||
Process theProcess_;
|
||||
|
||||
Subsys::SigTerm notifyTermination_;
|
||||
|
||||
|
||||
|
||||
/* === Interface Lifecycle === */
|
||||
|
|
@ -82,7 +91,9 @@ namespace proc {
|
|||
ServiceInstanceHandle serviceInstance_;
|
||||
|
||||
public:
|
||||
DummyPlayerService();
|
||||
DummyPlayerService(Subsys::SigTerm terminationHandle);
|
||||
|
||||
~DummyPlayerService() { notifyTermination_(); }
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue