stream type registry lifecycle

This commit is contained in:
Fischlurch 2008-09-24 05:46:26 +02:00
parent 14023d3024
commit 83b574bdea
4 changed files with 179 additions and 2 deletions

View file

@ -23,11 +23,52 @@
#include "proc/lumiera.hpp"
#include "proc/control/stypemanager.hpp"
#include "proc/control/styperegistry.hpp"
namespace control {
using lumiera::StreamType;
using lumiera::Symbol;
/* ======= stream type manager lifecycle ==========*/
STypeManager::STypeManager()
: reg_(0)
{
reset();
}
STypeManager::~STypeManager()
{ }
/** access the system-wide stream type manager instance.
* Implemented as singleton. */
lumiera::Singleton<STypeManager> STypeManager::instance;
void
STypeManager::reset()
{
reg_.reset(new Registry);
lumiera::Appconfig::lifecycle(ON_STREAMTYPES_RESET);
}
/** \par
* LifecycleHook, on which all the basic setup and configuration
* providing the pristine state of the stream type system has to be registered.
* @note plugins providing additional streamtype configuration should register
* their basic setup functions using this hook, which can be done via
* the C interface functions
*/
Symbol ON_STREAMTYPES_RESET ("ON_STREAMTYPES_RESET");
/* ======= implementation of the public interface ========= */
/** */
StreamType const&
@ -67,3 +108,12 @@ namespace control {
} // namespace control
// ==== C interface for registering setup of basic stream type configuration =======
void
lumiera_StreamType_registerInitFunction (void setupFun(void))
{
lumiera::LifecycleHook (control::ON_STREAMTYPES_RESET, setupFun);
}

View file

@ -26,7 +26,9 @@
#include "common/streamtype.hpp"
#include "common/singleton.hpp"
#include <boost/scoped_ptr.hpp>
namespace control {
@ -38,7 +40,12 @@ namespace control {
class STypeManager
{
class Registry;
boost::scoped_ptr<Registry> reg_;
public:
static lumiera::Singleton<STypeManager> instance;
/** (re)-access a media stream type using
* just a symbolic ID. Effectively this queries a default */
StreamType const& getType (Symbol sTypeID) ;
@ -62,8 +69,22 @@ namespace control {
////////////////TODO: design a mechanism allowing to add MediaImplLib implementations by plugin......
protected:
STypeManager();
~STypeManager();
friend class lumiera::singleton::StaticCreate<STypeManager>;
/** Lifecycle: reset all type registration information
* to the <i>generic pristine default</i> state. This includes
* hard wired defaults and defauls provided by type plugins, but
* excludes everything added by the session
*/
void reset() ;
};
extern Symbol ON_STREAMTYPES_RESET; ///< triggered to load the generic pristine default
} // namespace control
@ -74,4 +95,20 @@ namespace proc_interface {
} // namespace proc_interface
extern "C" { //TODO provide a separate header if some C code or plugin happens to need this...
/** any stream type implementation, which needs to be present on the
* pristine default level (without any session specific configuration),
* should register a setup function, which will be called on each
* STypemanager::reset()
*/
void
lumiera_StreamType_registerInitFunction (void setupFun(void));
// TODO provide a C interface usable from such a setupFun to access the STypeManager registration functions.
}
#endif

View file

@ -0,0 +1,86 @@
/*
STYPEREGISTRY.hpp - implementation of the registry for stream type descriptors
Copyright (C) Lumiera.org
2008, Hermann Vosseler <Ichthyostega@web.de>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/** @file styperegistry.hpp
** This is part of the \i implementation of the stream type manager (include).
** Only used in stypemanager.cpp and accompaning unit tests.
**
** @see control::STypeManager
** @see lumiera::StreamType
**
*/
#ifndef CONTROL_STYPEREGISTRY_H
#define CONTROL_STYPEREGISTRY_H
//#include "common/query.hpp"
//#include "common/util.hpp"
//#include "common/p.hpp"
//#include <set>
//#include <vector>
//#include <tr1/memory>
//#include <boost/format.hpp>
#include <boost/noncopyable.hpp>
namespace control {
// using lumiera::P;
// using lumiera::Query;
// using std::string;
// using boost::format;
namespace impl {
} // (End) impl namespace
/**
* @internal Helper for organizing preconfigured default objects.
* Maintaines a collection of objects known or encountered as "default"
* for a given type. This collection is ordered by "degree of constriction",
* which is implemented by counting the number of predicates in the query
* used to define or identify each object.
* Accessing an object identified by a query causes the query to be resolved
* (executed in prolog), which may result in some additional properties of
* the object being bound or specified.
* @todo as of 3/2008 the real query implementation is missing, and the
* exact behaviour has to be defined.
*/
class STypeManager::Registry : private boost::noncopyable
{
public:
};
} // namespace control
#endif

View file

@ -24,6 +24,7 @@
#include "common/test/run.hpp"
#include "common/util.hpp"
#include "proc/control/stypemanager.hpp"
#include "teststreamtypes.hpp"
#include <iostream>
@ -33,7 +34,9 @@ using std::cout;
namespace lumiera {
namespace test {
using control::STypeManager;
/*******************************************************************
* @test check the basic workings of the stream type handling.
@ -51,7 +54,8 @@ namespace lumiera {
void buildImplType ()
{
UNIMPLEMENTED ("Access/Factory for the STypeManager??");
STypeManager& typeManager = STypeManager::instance();
TODO ("set up a GAVL frame type");
TODO ("use this to retrieve an ImplFacade from the STypeManager");
UNIMPLEMENTED ("at least preliminary implementation of the MediaImplLib interface for lib GAVL");