2007-09-27 23:26:54 +02:00
|
|
|
/*
|
|
|
|
|
SESSION.hpp - holds the complete session to be edited by the user
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2008-03-10 04:25:03 +01:00
|
|
|
Copyright (C) Lumiera.org
|
|
|
|
|
2008, Hermann Vosseler <Ichthyostega@web.de>
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2007-09-27 23:26:54 +02:00
|
|
|
This program is free software; you can redistribute it and/or
|
|
|
|
|
modify it under the terms of the GNU General Public License as
|
2010-12-17 23:28:49 +01:00
|
|
|
published by the Free Software Foundation; either version 2 of
|
|
|
|
|
the License, or (at your option) any later version.
|
|
|
|
|
|
2007-09-27 23:26:54 +02:00
|
|
|
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.
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2007-09-27 23:26:54 +02:00
|
|
|
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.
|
2010-12-17 23:28:49 +01:00
|
|
|
|
2007-09-27 23:26:54 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** @file session.hpp
|
2013-10-25 06:34:38 +02:00
|
|
|
** @ingroup session
|
2007-09-27 23:26:54 +02:00
|
|
|
** Primary Interface to the current Session.
|
2016-12-03 05:42:34 +01:00
|
|
|
** The session interface can be used to discover session contents.
|
2009-11-08 20:13:11 +01:00
|
|
|
** Mostly, these objects within the session are MObject subclasses, but they
|
|
|
|
|
** are attached into the session by a Placement. Usually, you'd want to use
|
|
|
|
|
** the discovered objects to invoke operations on them; in most cases,
|
|
|
|
|
** invoking any mutating operation should be wrapped into a Command.
|
|
|
|
|
**
|
2007-09-27 23:26:54 +02:00
|
|
|
** The Interface Session is abstract and only accessible via the
|
|
|
|
|
** static field Session::current, which actually refers to a SessManager
|
2009-11-08 20:13:11 +01:00
|
|
|
** singleton instance. The latter acts as smart ptr-to-Impl for accessing the
|
|
|
|
|
** current session, but at the same time exposes a lifecycle/management API.
|
|
|
|
|
**
|
|
|
|
|
** @note if interested in the interplay of Session, SessManager and the
|
|
|
|
|
** internal service APIs (SessionServices), you should have a look
|
|
|
|
|
** at session-service-access-test.cpp, as this test creates a complete
|
|
|
|
|
** but simplified mock setup of the session and session manager, without
|
|
|
|
|
** any access and synchronisation and similar concerns, to read top down.
|
2007-09-27 23:26:54 +02:00
|
|
|
**
|
2010-03-08 05:26:09 +01:00
|
|
|
** @see session-structure-test.cpp
|
|
|
|
|
** @see timeline-sequence-handling-test.cpp
|
|
|
|
|
** @see session-modify-parts-test.cpp
|
2007-09-27 23:26:54 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef MOBJECT_SESSION_H
|
|
|
|
|
#define MOBJECT_SESSION_H
|
|
|
|
|
|
|
|
|
|
#include "proc/mobject/placement.hpp"
|
2010-03-27 16:26:22 +01:00
|
|
|
#include "proc/mobject/mobject-ref.hpp"
|
2012-12-01 08:44:07 +01:00
|
|
|
#include "common/query/defs-manager.hpp" ////////////////////////////TICKET #643 forward declare this?
|
2010-03-08 05:26:09 +01:00
|
|
|
#include "lib/ref-array.hpp"
|
2013-10-20 03:19:36 +02:00
|
|
|
#include "lib/depend.hpp"
|
2009-09-24 23:02:40 +02:00
|
|
|
#include "lib/symbol.hpp"
|
2010-03-08 05:26:09 +01:00
|
|
|
#include "lib/p.hpp"
|
2007-09-27 23:26:54 +02:00
|
|
|
|
2008-04-13 23:54:39 +02:00
|
|
|
#include <boost/noncopyable.hpp>
|
2014-04-03 22:42:48 +02:00
|
|
|
#include <memory>
|
2007-09-27 23:26:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-12-02 16:10:03 +01:00
|
|
|
namespace proc {
|
2010-03-08 05:26:09 +01:00
|
|
|
namespace asset {
|
2015-07-02 19:16:46 +02:00
|
|
|
class Timeline; typedef lib::P<Timeline> PTimeline;
|
|
|
|
|
class Sequence; typedef lib::P<Sequence> PSequence;
|
2010-03-08 05:26:09 +01:00
|
|
|
}
|
|
|
|
|
|
2009-06-06 06:18:37 +02:00
|
|
|
namespace mobject {
|
|
|
|
|
|
|
|
|
|
namespace session {
|
2007-09-27 23:26:54 +02:00
|
|
|
class SessManager;
|
2010-06-20 04:30:42 +02:00
|
|
|
class ElementQuery;
|
2007-09-27 23:26:54 +02:00
|
|
|
class Fixture;
|
2014-04-03 22:42:48 +02:00
|
|
|
typedef std::shared_ptr<Fixture> PFix;
|
2009-06-06 06:18:37 +02:00
|
|
|
}
|
2007-09-27 23:26:54 +02:00
|
|
|
|
|
|
|
|
typedef session::SessManager& PSess; ///< acts as a "PImpl" smart ptr
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The (current) Session holds all the user
|
|
|
|
|
* visible content to be edited and manipulated
|
2008-03-10 06:09:44 +01:00
|
|
|
* within the Lumiera Application. From a users
|
2007-09-27 23:26:54 +02:00
|
|
|
* perspective, it is a collection of Media Objects
|
|
|
|
|
* (--> MObject) placed (--> Placement) onto virtual
|
|
|
|
|
* Tracks.
|
|
|
|
|
*
|
|
|
|
|
* Opening a Session has effectively global consequences,
|
|
|
|
|
* because the Session defines the available Assets, and some
|
2010-03-08 05:26:09 +01:00
|
|
|
* kinds of Assets define default behaviour. Thus, access to the
|
|
|
|
|
* Session is similar to a Singleton, through \c Session::current
|
|
|
|
|
* Besides the SessionManager, several sub-interfaces are exposed
|
|
|
|
|
* as embedded components: DefaultsManger, timelines and sequences.
|
2007-09-27 23:26:54 +02:00
|
|
|
*
|
|
|
|
|
* @note Any client should be aware that the Session can be closed,
|
2009-06-06 06:18:37 +02:00
|
|
|
* replaced and loaded. The only way to access the Session is
|
2007-09-27 23:26:54 +02:00
|
|
|
* via a "PImpl" smart pointer session::PSess (which indeed is
|
|
|
|
|
* a reference to the SessManager and is accessible as the static
|
2010-03-08 05:26:09 +01:00
|
|
|
* field Session::current). Clients shouldn't try to get a direct
|
2007-09-27 23:26:54 +02:00
|
|
|
* pointer or reference to the Session object.
|
2013-10-25 06:34:38 +02:00
|
|
|
* @ingroup session
|
|
|
|
|
*
|
2007-09-27 23:26:54 +02:00
|
|
|
*/
|
2010-03-08 05:26:09 +01:00
|
|
|
class Session
|
|
|
|
|
: boost::noncopyable
|
2007-09-27 23:26:54 +02:00
|
|
|
{
|
|
|
|
|
protected:
|
2012-12-01 08:44:07 +01:00
|
|
|
typedef lumiera::query::DefsManager& DefaultsAccess;
|
2010-06-20 04:30:42 +02:00
|
|
|
typedef session::ElementQuery& ElementsAccess;
|
2010-03-08 05:26:09 +01:00
|
|
|
typedef lib::RefArray<asset::PTimeline>& TimelineAccess;
|
|
|
|
|
typedef lib::RefArray<asset::PSequence>& SequenceAccess;
|
|
|
|
|
|
|
|
|
|
|
2015-01-17 16:08:56 +01:00
|
|
|
Session (DefaultsAccess,
|
|
|
|
|
ElementsAccess,
|
|
|
|
|
TimelineAccess,
|
|
|
|
|
SequenceAccess) throw();
|
2009-11-08 19:47:51 +01:00
|
|
|
virtual ~Session ();
|
2010-03-08 05:26:09 +01:00
|
|
|
|
|
|
|
|
|
2007-09-27 23:26:54 +02:00
|
|
|
public:
|
2010-01-10 00:04:58 +01:00
|
|
|
static bool initFlag; ///////////////TICKET #518 yet another hack; actually need to care for session manager startup.
|
2010-03-08 05:26:09 +01:00
|
|
|
|
2010-06-20 04:30:42 +02:00
|
|
|
static session::SessManager& current; ///< access point to the current Session
|
2010-03-08 05:26:09 +01:00
|
|
|
|
2010-03-28 05:15:45 +02:00
|
|
|
DefaultsAccess defaults; ///< manages default configured objects
|
2010-06-20 04:30:42 +02:00
|
|
|
ElementsAccess elements;
|
2010-03-28 05:15:45 +02:00
|
|
|
TimelineAccess timelines; ///< collection of timelines (top level)
|
|
|
|
|
SequenceAccess sequences; ///< collection of sequences
|
2007-09-27 23:26:54 +02:00
|
|
|
|
2010-10-26 05:37:14 +02:00
|
|
|
virtual bool isValid () = 0;
|
|
|
|
|
virtual MObjectRef attach (PMO const& placement) = 0;
|
|
|
|
|
virtual bool detach (PMO const& placement) = 0;
|
2007-09-27 23:26:54 +02:00
|
|
|
|
2010-10-26 05:37:14 +02:00
|
|
|
virtual MObjectRef getRoot() = 0;
|
2010-03-27 16:26:22 +01:00
|
|
|
|
2010-10-26 05:37:14 +02:00
|
|
|
virtual session::PFix& getFixture () = 0;
|
|
|
|
|
virtual void rebuildFixture () = 0;
|
2007-09-27 23:26:54 +02:00
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2009-09-24 23:02:40 +02:00
|
|
|
extern const char* ON_SESSION_START; ///< triggered before loading any content into a newly created session
|
|
|
|
|
extern const char* ON_SESSION_INIT; ///< triggered when initialising a new session, after adding content
|
2009-11-09 05:21:59 +01:00
|
|
|
extern const char* ON_SESSION_READY; ///< triggered after session is completely functional and all APIs are open.
|
2009-09-24 23:02:40 +02:00
|
|
|
extern const char* ON_SESSION_END; ///< triggered before discarding an existing session
|
2009-08-09 19:22:07 +02:00
|
|
|
|
|
|
|
|
|
2009-06-06 06:18:37 +02:00
|
|
|
namespace session {
|
2007-09-27 23:26:54 +02:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* creation, access and Session lifecycle Interface.
|
|
|
|
|
* An instance is accessible via Session::current
|
|
|
|
|
*/
|
|
|
|
|
class SessManager : private boost::noncopyable
|
|
|
|
|
{
|
|
|
|
|
public:
|
2009-12-13 04:27:57 +01:00
|
|
|
/** diagnostics: session interface opened? */
|
|
|
|
|
virtual bool isUp () =0;
|
|
|
|
|
|
2007-09-27 23:26:54 +02:00
|
|
|
/** clear current session contents
|
|
|
|
|
* without resetting overall session config.
|
|
|
|
|
* Afterwards, the session will contain only one
|
2010-02-22 03:52:52 +01:00
|
|
|
* empty Sequence, while all Assets are retained.
|
2007-09-27 23:26:54 +02:00
|
|
|
*/
|
|
|
|
|
virtual void clear () =0;
|
|
|
|
|
|
2010-10-23 05:58:14 +02:00
|
|
|
/** shut down the current session cleanly.
|
|
|
|
|
* Includes discarding of all assets and unloading any
|
|
|
|
|
* config rules and additional state. Doesn't save anything.
|
|
|
|
|
* Typically invoked on shutdown of the session subsystem.
|
|
|
|
|
* @note next access will pull up a empty default session
|
|
|
|
|
*/
|
|
|
|
|
virtual void close () =0;
|
|
|
|
|
|
2007-09-27 23:26:54 +02:00
|
|
|
/** reset all session config and
|
|
|
|
|
* start with a pristine default session.
|
|
|
|
|
*/
|
|
|
|
|
virtual void reset () =0;
|
|
|
|
|
|
|
|
|
|
/** replace the current session by a new
|
2009-06-06 06:18:37 +02:00
|
|
|
* session loaded from serialised state.
|
2007-09-27 23:26:54 +02:00
|
|
|
*/
|
2009-11-08 19:47:51 +01:00
|
|
|
virtual void load () =0;
|
2007-09-27 23:26:54 +02:00
|
|
|
|
2009-06-06 06:18:37 +02:00
|
|
|
/** create a complete, serialised representation
|
2007-09-27 23:26:54 +02:00
|
|
|
* of the current session config and contents.
|
2017-04-17 21:54:36 +02:00
|
|
|
* @todo 2017 how actually to serialise, parameters, return value?
|
|
|
|
|
* @param snapshotID marker to tag the snapshot, like e.g. a timestamp
|
2007-09-27 23:26:54 +02:00
|
|
|
*/
|
2017-04-17 21:54:36 +02:00
|
|
|
virtual void save (string snapshotID) =0;
|
2007-09-27 23:26:54 +02:00
|
|
|
|
|
|
|
|
/** access to the current session object instance.
|
|
|
|
|
* This is the sole access path available for clients.
|
|
|
|
|
* @note there is no operator*
|
|
|
|
|
*/
|
|
|
|
|
virtual Session* operator-> () throw() =0;
|
|
|
|
|
|
2009-11-08 19:47:51 +01:00
|
|
|
virtual ~SessManager();
|
2007-09-27 23:26:54 +02:00
|
|
|
};
|
|
|
|
|
|
2008-02-16 02:47:01 +01:00
|
|
|
|
2008-03-10 08:38:59 +01:00
|
|
|
LUMIERA_ERROR_DECLARE (CREATE_SESSION); ///< unable to create basic session.
|
2008-02-16 02:47:01 +01:00
|
|
|
|
|
|
|
|
|
2007-09-27 23:26:54 +02:00
|
|
|
} // namespace mobject::session
|
|
|
|
|
|
2011-12-02 16:10:03 +01:00
|
|
|
}} // namespace proc::mobject
|
2007-09-27 23:26:54 +02:00
|
|
|
#endif
|