diff --git a/src/proc/mobject/session.hpp b/src/proc/mobject/session.hpp index cd1fa0cfb..5461f0ff0 100644 --- a/src/proc/mobject/session.hpp +++ b/src/proc/mobject/session.hpp @@ -120,9 +120,9 @@ namespace mobject { static session::SessManager& current; - DefaultsAccess defaults; - TimelineAccess timelines; - SequenceAccess sequences; + DefaultsAccess defaults; ///< manages default configured objects + TimelineAccess timelines; ///< collection of timelines (top level) + SequenceAccess sequences; ///< collection of sequences virtual bool isValid () = 0; virtual void attach (PMO& placement) = 0; diff --git a/src/proc/mobject/session/session-impl.cpp b/src/proc/mobject/session/session-impl.cpp index 1b1f1eb5f..3d9260bef 100644 --- a/src/proc/mobject/session/session-impl.cpp +++ b/src/proc/mobject/session/session-impl.cpp @@ -30,18 +30,6 @@ namespace mobject { namespace session { - /////////////////////////////////////////TODO temporary hack: use Meyer's singleton - namespace { - DefsManager& - getDummyDefaultsManager() - { - static scoped_ptr dummyInstance(0); - if (!dummyInstance) dummyInstance.reset (new DefsManager); - - return *dummyInstance; - } - } - /////////////////////////////////////////TODO temporary hack /** create a new empty session with default values. @@ -50,9 +38,12 @@ namespace session { * system (and this is desirable) */ SessionImpl::SessionImpl () - : Session( getDummyDefaultsManager() ) ///////TODO temporary hack - , pIdx_( MObject::create (getDummyDefaultsManager())) ////TODO temporary hack - , fixture(new Fixture) + : SessionInterfaceModules() + , Session( defaultsManager_ + , timelineRegistry_ + , sequenceRegistry_ ) + , contents_( MObject::create (defaultsManager_)) + , fixture_(new Fixture) { INFO (session, "new Session created."); } @@ -85,14 +76,14 @@ namespace session { void - SessionImpl::add (PMO& placement) + SessionImpl::attach (PMO& placement) { UNIMPLEMENTED ("add Placement to the current Session"); } bool - SessionImpl::remove (PMO& placement) + SessionImpl::detach (PMO& placement) { UNIMPLEMENTED ("search and remove a given Placement from current Session"); return false; // TODO diff --git a/src/proc/mobject/session/session-impl.hpp b/src/proc/mobject/session/session-impl.hpp index 8b7873b5d..c5733bd63 100644 --- a/src/proc/mobject/session/session-impl.hpp +++ b/src/proc/mobject/session/session-impl.hpp @@ -50,6 +50,7 @@ #include "proc/mobject/session/fixture.hpp" #include "proc/mobject/session/placement-index.hpp" #include "proc/mobject/session/session-services.hpp" +#include "proc/mobject/session/session-interface-modules.hpp" #include "proc/mobject/session/session-service-fetch.hpp" #include "proc/mobject/session/session-service-explore-scope.hpp" @@ -58,8 +59,6 @@ #include "proc/mobject/session/placement-index-query-resolver.hpp" -#include -#include @@ -67,22 +66,20 @@ namespace mobject { namespace session { - using std::vector; - using boost::scoped_ptr; - using std::tr1::shared_ptr; /** * Implementation class for the Session interface */ - class SessionImpl : public mobject::Session + class SessionImpl + : protected SessionInterfaceModules + , public mobject::Session { - PlacementIndex pIdx_; + PlacementIndex contents_; - PFix fixture; + PFix fixture_; - scoped_ptr defaultsManager_; ///////////TODO: later, this will be the real defaults manager. Currently this is just never initialised (11/09) /* ==== Session API ==== */ @@ -102,8 +99,8 @@ namespace session { PlacementIndex& getPlacementIndex() { - ENSURE (pIdx_.isValid()); - return pIdx_; + ENSURE (contents_.isValid()); + return contents_; } }; diff --git a/src/proc/mobject/session/session-interface-modules.hpp b/src/proc/mobject/session/session-interface-modules.hpp new file mode 100644 index 000000000..dbeea6ba0 --- /dev/null +++ b/src/proc/mobject/session/session-interface-modules.hpp @@ -0,0 +1,130 @@ +/* + SESSION-INTERFACE-MODULES.hpp - holds the complete session data to be edited by the user + + Copyright (C) Lumiera.org + 2010, 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 session-interface-modules.hpp + ** Self-contained sub-elements on the Session API. + ** Part of the Session interface is exposed as self-contained + ** interface modules -- both for notational convenience at the + ** usage site, and for keeping session implementation code manageable. + ** Clients access these modules as nested parts of the public Session interface + ** through references exposing just the respective interfaces, while the actual + ** implementation is located in-place (within the SesssionImpl object), packaged + ** into a non-public baseclass. + ** - the DefsManager acts as frontend to the system of default configurations + ** and config rules, allowing to retrieve the \em default version of various + ** kinds of objects + ** - the top-level Timeline (structural assets) act as facade and entry point + ** to the high-level-model (session contents). There is an table of timelines, + ** managed automatically and kept in sync with the session::Binding elements + ** located directly below model root. + ** - likewise there is an table of all Sequence (structural assets), which + ** correspond to the roots of track trees, attached below model root. + ** + ** \par maintaining the link between session, timelines and sequences + ** Timeline and Sequence are implemented as asset::Struct, causing them to be + ** maintained by the AssetManager, which in turn is attached to the session::Root + ** (WIP 3/2010: yet to be implemented). Creation and destruction of timelines and + ** sequences is closely connected to some structural changes within the model + ** - Timeline is related to session::Binding, where the timelines are leading + ** and the binding elements are dependent on both a timeline and a sequence + ** - Sequence is related to a Placement -- but only if attached + ** immediately below model root; here the tracks are leading and the sequences + ** are completely dependent. + ** In any case, ctor and dtor of Timeline and Sequence have to care for proper + ** registration into the SessionInterfaceModules for timelines and sequences + ** respectively. This is accomplished by using kind-of a backdoor, a SessionServices + ** (proc internal API) definition, allowing direct communication on implementation + ** level, without the need to expose this access point on the public session API. + ** The impl::ElementTracker implemented in this sourcefile here relieves these + ** calls to maintain a list of asset smart-ptrs + ** + ** @see SessionImpl + ** @see session-services.hpp + ** + */ + + +#ifndef MOBJECT_SESSION_INTERFACE_MODULES_H +#define MOBJECT_SESSION_INTERFACE_MODULES_H + +#include "lib/p.hpp" +#include "lib/ref-array-impl.hpp" + + + + +namespace mobject { +namespace session { + + namespace impl { // impl: list of elements to track + + using lumiera::P; + + /** + * Custom implementation of the RefArray interface, + * used by the Session to keep track of all timelines + * and sequences. The registration/deregistration functions + * are accessible as SessionServices + */ + template + class ElementTracker + : public lib::RefArrayVectorWrapper > + { + public: + void + add (P const& asset) + { + UNIMPLEMENTED ("attach entry to session"); + } + + void + remove (P const& asset) + { + UNIMPLEMENTED ("detach entry from session"); + } + }; + + } //(End) impl list of elements to track + + + typedef impl::ElementTracker TimelineTracker; + typedef impl::ElementTracker SequenceTracker; + + + /** + * Collection of implementation components, + * providing self-contained sub-elements + * exposed on the public Session API. + */ + struct SessionInterfaceModules + : boost::noncopyable + { + DefsManager defaultsManager_; + TimelineTracker timelineRegistry_; + SequenceTracker sequenceRegistry_; + }; + + + +}} // namespace mobject::session +#endif diff --git a/tests/43session.tests b/tests/43session.tests index d395965c5..6309f172a 100644 --- a/tests/43session.tests +++ b/tests/43session.tests @@ -25,6 +25,10 @@ PLANNED "DeleteClip_test" DeleteClip_test < + + 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. + +* *****************************************************/ + + +#include "lib/test/run.hpp" +//#include "proc/mobject/session.hpp" +//#include "proc/mobject/mobject-ref.hpp" +//#include "proc/mobject/session/binding.hpp" +//#include "proc/mobject/session/fixture.hpp" // TODO only temporarily needed +//#include "proc/assetmanager.hpp" +#include "proc/asset/timeline.hpp" +#include "proc/asset/sequence.hpp" +//#include "proc/asset/pipe.hpp" +//#include "lib/lumitime.hpp" +//#include "lib/query.hpp" +//#include "lib/util.hpp" + +//#include + +//using util::isSameObject; +//using util::contains; +//using std::string; +//using std::cout; + + +namespace mobject { +namespace session { +namespace test { + +// using proc_interface::AssetManager; +// using proc_interface::PAsset; + + using asset::PTimeline; + using asset::PSequence; +// using asset::RBinding; +// using asset::RTrack; +// using asset::Pipe; + +// using lumiera::Query; +// using lumiera::Time; + + + /******************************************************************************** + * @test verify the tracking of special session/model elements, to be exposed + * through an self-contained interface module on the session API. + * + * @todo WIP-WIP-WIP + * + * @see timeline-sequence-handling-test.cpp + * @see session-interface-modules.hpp + * @see ref-array-test.cpp + */ + class SessionElementTracker_test : public Test + { + virtual void + run (Arg) + { + verify_trackingMechanism(); + verify_integration(); + } + + + void + verify_trackingMechanism() + { + UNIMPLEMENTED ("use a test dummy class and do a dry run of the ElementTracker"); + } + + + void + verify_integration() + { + Session::current.reset(); + CHECK (Session::current.isUp()); + + PSess sess = Session::current; + CHECK (sess->isValid()); + + uint num_timelines = sess->timelines.size(); + CHECK (0 < num_timelines); + + PTimeline specialTimeline (asset::Struct::create (Query ("id(testical)"))); + CHECK (specialTimeline); + CHECK (num_timelines + 1 == sess->timelines.size()); + CHECK (specialTimeline == session->timelines[num_timelines]); + CHECK (specialTimeline.use_count() == 3); // we, the AssetManager and the session + + PTimeline anotherTimeline (asset::Struct::create (Query ())); + CHECK (num_timelines + 2 == sess->timelines.size()); + CHECK (specialTimeline == session->timelines[num_timelines]); + CHECK (anotherTimeline == session->timelines[num_timelines+1]); // new one got appended at the end + + AssetManager& assetM (AssetManager::instance()); + CHECK (assetM.known (specialTimeline->getID())); + assetM.remove (specialTimeline->getID()); //////////////TICKET #550 + CHECK (!assetM.known (specialTimeline->getID())); + + CHECK (num_timelines + 1 == sess->timelines.size()); + CHECK (anotherTimeline == session->timelines[num_timelines]); // moved to the previous slot + CHECK (specialTimeline.use_count() == 1); // we're holding the last reference + } + }; + + + /** Register this test class... */ + LAUNCHER (SessionElementTracker_test, "unit session"); + + + +}}} // namespace mobject::session::test