Constness changes
[melted] / mlt++ / src / MltProperties.cpp
index 9558fcc..f1b2b56 100644 (file)
  */
 
 #include "MltProperties.h"
+#include "MltEvent.h"
 using namespace Mlt;
 
-PropertiesInstance::PropertiesInstance( ) :
-       destroy( true ),
+Properties::Properties( ) :
        instance( NULL )
 {
        instance = mlt_properties_new( );
 }
 
-PropertiesInstance::PropertiesInstance( Properties &properties ) :
-       destroy( false ),
+Properties::Properties( bool dummy ) :
+       instance( NULL )
+{
+}
+
+Properties::Properties( Properties &properties ) :
        instance( properties.get_properties( ) )
 {
+       inc_ref( );
 }
 
-PropertiesInstance::PropertiesInstance( mlt_properties properties ) :
-       destroy( false ),
+Properties::Properties( mlt_properties properties ) :
        instance( properties )
 {
+       inc_ref( );
 }
 
-PropertiesInstance::~PropertiesInstance( )
+Properties::Properties( const char *file ) :
+       instance( NULL )
 {
-       if ( destroy )
-               mlt_properties_close( instance );
+       instance = mlt_properties_load( file );
+}
+
+Properties::~Properties( )
+{
+       mlt_properties_close( instance );
+}
+
+mlt_properties Properties::get_properties( )
+{
+       return instance;
+}
+
+int Properties::inc_ref( )
+{
+       return mlt_properties_inc_ref( get_properties( ) );
+}
+
+int Properties::dec_ref( )
+{
+       return mlt_properties_dec_ref( get_properties( ) );
+}
+
+int Properties::ref_count( )
+{
+       return mlt_properties_ref_count( get_properties( ) );
+}
+
+void Properties::block( void *object )
+{
+       mlt_events_block( get_properties( ), object != NULL ? object : get_properties( ) );
+}
+
+void Properties::unblock( void *object )
+{
+       mlt_events_unblock( get_properties( ), object != NULL ? object : get_properties( ) );
+}
+
+void Properties::fire_event( const char *event )
+{
+       mlt_events_fire( get_properties( ), ( char * )event, NULL );
 }
 
 bool Properties::is_valid( )
@@ -56,49 +101,161 @@ int Properties::count( )
        return mlt_properties_count( get_properties( ) );
 }
 
-char *Properties::get( char *name )
+char *Properties::get( const char *name )
 {
        return mlt_properties_get( get_properties( ), name );
 }
 
-int Properties::get_int( char *name )
+int Properties::get_int( const char *name )
 {
        return mlt_properties_get_int( get_properties( ), name );
 }
 
-double Properties::get_double( char *name )
+double Properties::get_double( const char *name )
 {
        return mlt_properties_get_double( get_properties( ), name );
 }
 
-void *Properties::get_data( char *name, int &size )
+void *Properties::get_data( const char *name, int &size )
 {
        return mlt_properties_get_data( get_properties( ), name, &size );
 }
 
-int Properties::set( char *name, char *value )
+void *Properties::get_data( const char *name )
+{
+       return mlt_properties_get_data( get_properties( ), name, NULL );
+}
+
+int Properties::set( const char *name, const char *value )
 {
        return mlt_properties_set( get_properties( ), name, value );
 }
 
-int Properties::set( char *name, int value )
+int Properties::set( const char *name, int value )
 {
        return mlt_properties_set_int( get_properties( ), name, value );
 }
 
-int Properties::set( char *name, double value )
+int Properties::set( const char *name, double value )
 {
        return mlt_properties_set_double( get_properties( ), name, value );
 }
 
-int Properties::set( char *name, void *value, int size, mlt_destructor destructor, mlt_serialiser serialiser )
+int Properties::set( const char *name, void *value, int size, mlt_destructor destructor, mlt_serialiser serialiser )
 {
        return mlt_properties_set_data( get_properties( ), name, value, size, destructor, serialiser );
 }
 
-mlt_properties PropertiesInstance::get_properties( )
+int Properties::pass_values( Properties &that, const char *prefix )
 {
-       return instance;
+       return mlt_properties_pass( get_properties( ), that.get_properties( ), prefix );
+}
+
+int Properties::parse( const char *namevalue )
+{
+       return mlt_properties_parse( get_properties( ), namevalue );
+}
+
+char *Properties::get_name( int index )
+{
+       return mlt_properties_get_name( get_properties( ), index );
+}
+
+char *Properties::get( int index )
+{
+       return mlt_properties_get_value( get_properties( ), index );
+}
+
+void *Properties::get_data( int index, int &size )
+{
+       return mlt_properties_get_data_at( get_properties( ), index, &size );
+}
+
+void Properties::mirror( Properties &that )
+{
+       mlt_properties_mirror( get_properties( ), that.get_properties( ) );
+}
+
+int Properties::inherit( Properties &that )
+{
+       return mlt_properties_inherit( get_properties( ), that.get_properties( ) );
+}
+
+int Properties::rename( const char *source, const char *dest )
+{
+       return mlt_properties_rename( get_properties( ), source, dest );
+}
+
+void Properties::dump( FILE *output )
+{
+       mlt_properties_dump( get_properties( ), output );
+}
+
+void Properties::debug( const char *title, FILE *output )
+{
+       mlt_properties_debug( get_properties( ), title, output );
+}
+
+void Properties::load( const char *file )
+{
+       mlt_properties properties = mlt_properties_load( file );
+       if ( properties != NULL )
+               mlt_properties_pass( get_properties( ), properties, "" );
+       mlt_properties_close( properties );
 }
 
+int Properties::save( const char *file )
+{
+#ifdef WIN32
+       return mlt_properties_save( get_properties( ), file );
+#else
+       int error = 0;
+       FILE *f = fopen( file, "w" );
+       if ( f != NULL )
+       {
+               dump( f );
+               fclose( f );
+       }
+       else
+       {
+               error = 1;
+       }
+       return error;
+#endif
+}
+
+#if defined( __DARWIN__ ) && GCC_VERSION < 40000
+
+Event *Properties::listen( char *id, void *object, void (*listener)( ... ) )
+{
+       mlt_event event = mlt_events_listen( get_properties( ), object, id, ( mlt_listener )listener );
+       return new Event( event );
+}
+
+#else
+
+Event *Properties::listen( char *id, void *object, mlt_listener listener )
+{
+       mlt_event event = mlt_events_listen( get_properties( ), object, id, listener );
+       return new Event( event );
+}
+
+#endif
+
+Event *Properties::setup_wait_for( const char *id )
+{
+       return new Event( mlt_events_setup_wait_for( get_properties( ), id ) );
+}
+
+void Properties::delete_event( Event *event )
+{
+       delete event;
+}
+
+void Properties::wait_for( Event *event, bool destroy )
+{
+       mlt_events_wait_for( get_properties( ), event->get_event( ) );
+       if ( destroy )
+               mlt_events_close_wait_for( get_properties( ), event->get_event( ) );
+}