2010-03-24 05:00:06 +01:00
/*
STRUCT - SCHEME . hpp - naming and designation scheme for structural assets
Copyright ( C ) Lumiera . org
2010 , 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 0213 9 , USA .
*/
/** @file struct-scheme.hpp
* * Naming and labelling scheme for structural assets .
* * Preconfigured traits data for the relevant types encountered in
* * Lumiera ' s session data model .
* *
* * @ see struct - factory - impl . hpp
* * @ see entry - id . hpp
* *
*/
# ifndef ASSET_STRUCT_SCHEME_H
# define ASSET_STRUCT_SCHEME_H
//#include "proc/mobject/session.hpp"
//#include "proc/mobject/mobject.hpp"
# include "lib/symbol.hpp"
//#include "lib/error.hpp"
//#include "lib/util.hpp"
//#include <boost/format.hpp>
# include <boost/format.hpp>
using boost : : format ;
/////////////////////////////////////////////////////////TODO needs to be pushed down into a *.cpp
2010-03-27 15:26:36 +01:00
# include <cstdlib>
2010-03-24 05:00:06 +01:00
//using mobject::Session;
//using mobject::MObject;
using lib : : Symbol ;
//using util::isnil;
//using util::contains;
//using asset::Query;
//using lumiera::query::LUMIERA_ERROR_CAPABILITY_QUERY;
//using lumiera::query::extractID;
2010-03-29 03:27:47 +02:00
namespace mobject {
namespace session {
class Track ;
class Clip ;
} }
2010-03-24 05:00:06 +01:00
namespace asset {
class Track ;
class Pipe ;
class ProcPatt ;
class Timeline ;
class Sequence ;
namespace idi {
2010-03-29 03:27:47 +02:00
2010-03-24 05:00:06 +01:00
// structural asset ID scheme ///////////////////////////////////////////////////////////TICKET #565
template < class STRU >
struct StructTraits
{
static Symbol namePrefix ;
static Symbol catFolder ;
static Symbol idSymbol ;
} ;
2010-03-29 03:27:47 +02:00
///////////////////////////////////////////////////////////////////////////////////////////TICKET #581 intending to abandon asset::Track in favour of a plain EntryID
template < > Symbol StructTraits < asset : : Track > : : namePrefix = " track " ;
template < > Symbol StructTraits < asset : : Track > : : catFolder = " tracks " ;
template < > Symbol StructTraits < asset : : Track > : : idSymbol = " track " ;
template < > Symbol StructTraits < mobject : : session : : Track > : : namePrefix = " track " ;
template < > Symbol StructTraits < mobject : : session : : Track > : : catFolder = " tracks " ;
template < > Symbol StructTraits < mobject : : session : : Track > : : idSymbol = " track " ;
template < > Symbol StructTraits < mobject : : session : : Clip > : : namePrefix = " clip " ;
template < > Symbol StructTraits < mobject : : session : : Clip > : : catFolder = " clips " ;
template < > Symbol StructTraits < mobject : : session : : Clip > : : idSymbol = " clip " ;
2010-03-24 05:00:06 +01:00
2010-03-27 16:26:22 +01:00
template < > Symbol StructTraits < Pipe > : : namePrefix = " pipe " ;
template < > Symbol StructTraits < Pipe > : : catFolder = " pipes " ;
template < > Symbol StructTraits < Pipe > : : idSymbol = " pipe " ;
2010-03-24 05:00:06 +01:00
2010-03-27 16:26:22 +01:00
template < > Symbol StructTraits < const ProcPatt > : : namePrefix = " patt " ;
template < > Symbol StructTraits < const ProcPatt > : : catFolder = " build-templates " ;
template < > Symbol StructTraits < const ProcPatt > : : idSymbol = " procPatt " ;
2010-03-24 05:00:06 +01:00
2010-03-27 16:26:22 +01:00
template < > Symbol StructTraits < Timeline > : : namePrefix = " tL " ;
template < > Symbol StructTraits < Timeline > : : catFolder = " timelines " ;
template < > Symbol StructTraits < Timeline > : : idSymbol = " timeline " ;
2010-03-24 05:00:06 +01:00
2010-03-27 16:26:22 +01:00
template < > Symbol StructTraits < Sequence > : : namePrefix = " seq " ;
template < > Symbol StructTraits < Sequence > : : catFolder = " sequences " ;
template < > Symbol StructTraits < Sequence > : : idSymbol = " sequence " ;
2010-03-24 05:00:06 +01:00
2010-03-27 15:26:36 +01:00
/* catch-all defaults */
template < class X >
2010-03-27 16:26:22 +01:00
Symbol StructTraits < X > : : idSymbol = typeid ( X ) . name ( ) ; ////////////////////TICKET #583 this default works but is ugly
2010-03-27 15:26:36 +01:00
template < class X >
2010-03-27 16:26:22 +01:00
Symbol StructTraits < X > : : catFolder = StructTraits < X > : : idSymbol ;
2010-03-27 15:26:36 +01:00
template < class X >
2010-03-27 16:26:22 +01:00
Symbol StructTraits < X > : : namePrefix = StructTraits < X > : : idSymbol ;
2010-03-27 15:26:36 +01:00
2010-03-24 05:00:06 +01:00
template < class STRU >
inline string
generateSymbolID ( )
{
static uint i = 0 ;
2010-03-29 03:27:47 +02:00
static format namePattern ( " %s.%03d " ) ;
2010-03-24 05:00:06 +01:00
/////////////////////////////////////////////////////////TODO needs to be pushed down into a *.cpp
return str ( namePattern % StructTraits < STRU > : : namePrefix % ( + + i ) ) ;
}
} } // namespace asset::idi
# endif