diff --git a/src/proc/control/stypemanager.cpp b/src/proc/control/stypemanager.cpp index 4f67ac063..330d9581e 100644 --- a/src/proc/control/stypemanager.cpp +++ b/src/proc/control/stypemanager.cpp @@ -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::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); +} diff --git a/src/proc/control/stypemanager.hpp b/src/proc/control/stypemanager.hpp index 77778a4ef..02edaeb2d 100644 --- a/src/proc/control/stypemanager.hpp +++ b/src/proc/control/stypemanager.hpp @@ -26,7 +26,9 @@ #include "common/streamtype.hpp" +#include "common/singleton.hpp" +#include namespace control { @@ -38,7 +40,12 @@ namespace control { class STypeManager { + class Registry; + boost::scoped_ptr reg_; + public: + static lumiera::Singleton 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; + + /** Lifecycle: reset all type registration information + * to the generic pristine default 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 diff --git a/src/proc/control/styperegistry.hpp b/src/proc/control/styperegistry.hpp new file mode 100644 index 000000000..5104a6df8 --- /dev/null +++ b/src/proc/control/styperegistry.hpp @@ -0,0 +1,86 @@ +/* + STYPEREGISTRY.hpp - implementation of the registry for stream type descriptors + + Copyright (C) Lumiera.org + 2008, Hermann Vosseler + + 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 +//#include +//#include +//#include +#include + + +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 diff --git a/tests/common/streamtypebasicstest.cpp b/tests/common/streamtypebasicstest.cpp index af6d3f764..d12dee470 100644 --- a/tests/common/streamtypebasicstest.cpp +++ b/tests/common/streamtypebasicstest.cpp @@ -24,6 +24,7 @@ #include "common/test/run.hpp" #include "common/util.hpp" +#include "proc/control/stypemanager.hpp" #include "teststreamtypes.hpp" #include @@ -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");