Object validity checks
authorlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Mon, 16 Aug 2004 06:48:51 +0000 (06:48 +0000)
committerlilo_booter <lilo_booter@d19143bc-622f-0410-bfdd-b5b2a6649095>
Mon, 16 Aug 2004 06:48:51 +0000 (06:48 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt++@366 d19143bc-622f-0410-bfdd-b5b2a6649095

mlt++/README
mlt++/src/MltProperties.cpp
mlt++/src/MltProperties.h
mlt++/test/play.cpp

index 26cc441..f4e8bed 100644 (file)
@@ -82,6 +82,9 @@ SPECIAL CASES
        This excludes the use of the RTTI to determine the real type of the object -
        this can only be done by parsing the objects properties.
 
+       Non-NULL objects may be invalid - always use the is_valid method to
+       check validity before use.
+
 LIMITATIONS
 -----------
 
index 72dcba3..9558fcc 100644 (file)
@@ -46,6 +46,11 @@ PropertiesInstance::~PropertiesInstance( )
                mlt_properties_close( instance );
 }
 
+bool Properties::is_valid( )
+{
+       return get_properties( ) != NULL;
+}
+
 int Properties::count( )
 {
        return mlt_properties_count( get_properties( ) );
index c9429c1..51d0952 100644 (file)
@@ -32,6 +32,7 @@ namespace Mlt
        {
                public:
                        virtual mlt_properties get_properties( ) = 0;
+                       bool is_valid( );
                        int count( );
                        char *get( char *name );
                        int get_int( char *name );
@@ -41,6 +42,7 @@ namespace Mlt
                        int set( char *name, int value );
                        int set( char *name, double value );
                        int set( char *name, void *value, int size, mlt_destructor destroy = NULL, mlt_serialiser serial = NULL );
+
        };
        
        /** Instance class.
index 5920a4b..1707d05 100644 (file)
@@ -11,9 +11,14 @@ using namespace Mlt;
 int main( int argc, char **argv )
 {
        Factory::init( NULL );
+       Producer *producer = Factory::producer( argv[ 1 ] );
+       if ( !producer->is_valid( ) )
+       {
+               cerr << "Can't construct producer for " << argv[ 1 ] << endl;
+               return 0;
+       }
        Consumer *consumer = Factory::consumer( "sdl" );
        consumer->set( "rescale", "none" );
-       Producer *producer = Factory::producer( argv[ 1 ] );
        Filter *filter = Factory::filter( "greyscale" );
        filter->connect( *producer );
        consumer->connect( *filter );