2 * mlt_factory.c -- the factory method interfaces
3 * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
4 * Author: Charles Yates <charles.yates@pandora.be>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 #include "mlt_factory.h"
23 #include "mlt_repository.h"
24 #include "mlt_properties.h"
28 /** Singleton repositories
31 static mlt_properties object_list
= NULL
;
32 static mlt_repository producers
= NULL
;
33 static mlt_repository filters
= NULL
;
34 static mlt_repository transitions
= NULL
;
35 static mlt_repository consumers
= NULL
;
37 /** Construct the factories.
40 int mlt_factory_init( char *prefix
)
42 // If no directory is specified, default to install directory
46 // Create the object list.
47 object_list
= calloc( sizeof( struct mlt_properties_s
), 1 );
48 mlt_properties_init( object_list
, NULL
);
50 // Create a repository for each service type
51 producers
= mlt_repository_init( object_list
, prefix
, "producers.dat", "mlt_create_producer" );
52 filters
= mlt_repository_init( object_list
, prefix
, "filters.dat", "mlt_create_filter" );
53 transitions
= mlt_repository_init( object_list
, prefix
, "transitions.dat", "mlt_create_transition" );
54 consumers
= mlt_repository_init( object_list
, prefix
, "consumers.dat", "mlt_create_consumer" );
59 /** Fetch a producer from the repository.
62 mlt_producer
mlt_factory_producer( char *service
, void *input
)
64 return ( mlt_producer
)mlt_repository_fetch( producers
, service
, input
);
67 /** Fetch a filter from the repository.
70 mlt_filter
mlt_factory_filter( char *service
, void *input
)
72 return ( mlt_filter
)mlt_repository_fetch( filters
, service
, input
);
75 /** Fetch a transition from the repository.
78 mlt_transition
mlt_factory_transition( char *service
, void *input
)
80 return ( mlt_transition
)mlt_repository_fetch( transitions
, service
, input
);
83 /** Fetch a consumer from the repository
86 mlt_consumer
mlt_factory_consumer( char *service
, void *input
)
88 return ( mlt_consumer
)mlt_repository_fetch( consumers
, service
, input
);
91 /** Close the factory.
94 void mlt_factory_close( )
96 mlt_repository_close( producers
);
97 mlt_repository_close( filters
);
98 mlt_repository_close( transitions
);
99 mlt_repository_close( consumers
);
100 mlt_properties_close( object_list
);