2007-09-02 18:48:22 +02:00
/*
STRUCT . hpp - key abstraction : structural asset
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-02 18:48:22 +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-02 18:48:22 +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-02 18:48:22 +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 0213 9 , USA .
2010-12-17 23:28:49 +01:00
2007-09-02 18:48:22 +02:00
*/
2007-09-16 03:02:05 +02:00
/** @file struct.hpp
2010-02-22 03:52:52 +01:00
* * Structural parts of the Session ( e . g . Tracks ) can be reflected
* * into the " bookkeeping view " as a specific Kind of Asset .
2010-03-06 04:30:12 +01:00
* * For the different \ em kinds of Assets , we use sub - interfaces inheriting
* * from the general Asset interface , each of which expose a distinguishing feature .
2010-10-29 04:28:46 +02:00
* * In the case of structural assets , the key point is the ability to retrieve an
* * instance based on a capabilities query ; structural assets are typically created
2010-03-06 04:30:12 +01:00
* * on demand , just by referral . Thus , the collection of these assets provides a map
* * for exploring the current session ' s structure and allow for tweaking of the
* * default behaviour .
2010-10-31 02:02:31 +01:00
* * - Track acts as unique track ID < i > ( note : to be removed and replaced by a plain \ c entryID ) < / i >
2010-03-06 04:30:12 +01:00
* * - Timeline and Sequence are facades , part of the session API
* * - Pipe is an attachment point for wiring connections and defines a StreamType
* * - ProcPatt is used as a blueprint in the build process , a standard connection pattern
* *
* * \ par access and creation
* * asset : : Struct instances are created on demand ; the interface is to invoke the
* * StructFactory with a ( typed ) Query describing properties or capabilities .
* * In case this query succeeds , an existing asset will be returned , otherwise
* * a suitable new instance is created automatically . Typically , structural assets
* * aren ' t deleted . Doing so would require a dedicated function which not only drops
* * an asset instance from AssetManager , but also ensures removal of all properties
* * within the model which could cause automatic re - creation of this asset . E . g .
* * purging a track asset ( = unique trackID ) requires removing or disconnecting
* * all placements referring to this track , which could be sub tracks , clips ,
* * effects , automation or labels .
* *
2013-10-25 06:34:38 +02:00
* * @ ingroup asset
2010-03-06 04:30:12 +01:00
* * @ see asset . hpp for explanation regarding asset IDs
2007-09-16 03:02:05 +02:00
* * @ see StructFactory creating concrete asset : : Struct instances
* *
*/
2007-09-02 18:48:22 +02:00
# ifndef ASSET_STRUCT_H
# define ASSET_STRUCT_H
2010-10-29 04:28:46 +02:00
# include "lib/symbol.hpp"
2012-12-01 08:44:07 +01:00
# include "proc/asset.hpp"
# include "common/query.hpp"
2007-09-02 18:48:22 +02:00
2012-10-14 01:30:08 +02:00
# include <boost/noncopyable.hpp>
2008-02-10 17:23:16 +01:00
# include <boost/scoped_ptr.hpp>
# include <string>
2008-01-07 18:16:03 +01:00
2007-09-02 18:48:22 +02:00
2011-12-02 16:10:03 +01:00
namespace proc {
2009-01-05 16:17:17 +01:00
namespace asset {
2008-03-31 03:21:28 +02:00
using std : : string ;
using boost : : scoped_ptr ;
2012-12-01 08:44:07 +01:00
using lumiera : : Query ;
2010-10-29 04:28:46 +02:00
using lib : : Symbol ;
2007-09-16 03:02:05 +02:00
class Struct ;
class StructFactory ;
2008-02-10 17:23:16 +01:00
class StructFactoryImpl ;
2008-02-14 04:12:30 +01:00
class Pipe ;
2007-09-16 03:02:05 +02:00
template < >
class ID < Struct > : public ID < Asset >
{
public :
2010-11-27 05:11:02 +01:00
ID ( HashVal id ) ;
2007-09-16 03:02:05 +02:00
ID ( const Struct & ) ;
} ;
2010-11-27 05:11:02 +01:00
2007-09-02 18:48:22 +02:00
/**
* key abstraction : structural asset
2010-03-06 04:30:12 +01:00
* Created automatically as a sideeffect of building the structure
* of the high - level - model ( session contents ) , thus providing IDs
* for later referral , search and attachment of metadata .
*
* Examples being tracks , sequences , timelines , pipes , processing patterns
2010-10-29 04:28:46 +02:00
* @ note embedded access point to instance creation or retrieval
* through the static field # retrieve
2007-09-02 18:48:22 +02:00
*/
class Struct : public Asset
{
2007-09-16 03:02:05 +02:00
public :
2010-10-29 04:28:46 +02:00
static StructFactory retrieve ;
2007-09-02 18:48:22 +02:00
2010-02-28 07:17:12 +01:00
virtual const ID < Struct > &
getID ( ) const ///< @return ID of kind asset::Struct
2007-09-16 03:02:05 +02:00
{
return static_cast < const ID < Struct > & > ( Asset : : getID ( ) ) ;
}
2008-02-15 02:56:25 +01:00
2007-09-16 03:02:05 +02:00
protected :
2008-01-12 18:19:37 +01:00
Struct ( const Asset : : Ident & idi ) : Asset ( idi ) { }
2007-09-16 03:02:05 +02:00
} ;
// definition of ID<Struct> ctors is possible now,
2010-02-28 07:17:12 +01:00
// after providing full definition of class Struct
2010-10-31 02:02:31 +01:00
2010-11-27 05:11:02 +01:00
inline ID < Struct > : : ID ( HashVal id ) : ID < Asset > ( id ) { } ;
2007-09-16 03:02:05 +02:00
inline ID < Struct > : : ID ( const Struct & stru ) : ID < Asset > ( stru . getID ( ) ) { } ;
2008-01-14 01:01:11 +01:00
2007-09-16 03:02:05 +02:00
/**
2009-01-05 16:17:17 +01:00
* Factory specialised for creating Structural Asset objects .
2007-09-16 03:02:05 +02:00
*/
2012-10-14 01:30:08 +02:00
class StructFactory
: boost : : noncopyable
2007-09-16 03:02:05 +02:00
{
2008-02-10 17:23:16 +01:00
scoped_ptr < StructFactoryImpl > impl_ ;
2010-10-31 02:02:31 +01:00
2008-02-10 17:23:16 +01:00
protected :
StructFactory ( ) ;
friend class Struct ;
2010-10-31 02:02:31 +01:00
2008-02-10 17:23:16 +01:00
2007-09-16 03:02:05 +02:00
public :
2008-01-07 18:16:03 +01:00
template < class STRU >
2010-10-29 04:28:46 +02:00
P < STRU > operator ( ) ( Query < STRU > const & query ) ;
2008-01-14 01:01:11 +01:00
2010-03-27 16:26:22 +01:00
// P<Timeline> operator() (MORef<Binding>); ///////////TODO doesn't this create circular includes?? Any better idea how to refer to an existing binding?
2008-02-10 17:23:16 +01:00
2010-10-29 04:28:46 +02:00
template < class STRU >
P < STRU > newInstance ( Symbol nameID = " " ) ;
2010-10-29 06:09:06 +02:00
2010-11-02 04:09:06 +01:00
template < class STRU >
P < STRU > made4fake ( Query < STRU > const & query ) ; ///< @warning to be removed in Alpha when using a real resolution engine /////TICKET #710
2010-10-29 06:09:06 +02:00
P < Pipe > newPipe ( string pipeID , string streamID ) ;
2007-09-02 18:48:22 +02:00
} ;
2010-10-31 02:02:31 +01:00
2011-12-02 16:10:03 +01:00
} } // namespace proc::asset
2007-09-02 18:48:22 +02:00
# endif