TuttleOFX  1
TuttleOFX/libraries/tuttle/src/tuttle/host/ofx/OfxhInteractSuite.cpp
Go to the documentation of this file.
00001 #include "OfxhInteractSuite.hpp"
00002 #include "OfxhInteract.hpp"
00003 
00004 namespace tuttle {
00005 namespace host {
00006 namespace ofx {
00007 namespace interact {
00008 
00009 namespace {
00010 
00011 OfxStatus interactSwapBuffers( OfxInteractHandle handle )
00012 {
00013         try
00014         {
00015                 interact::OfxhInteract* interactInstance = reinterpret_cast<interact::OfxhInteract*>( handle );
00016                 if( !interactInstance )
00017                         return kOfxStatErrBadHandle;
00018 
00019                 interactInstance->swapBuffers();
00020 
00021                 return kOfxStatOK;
00022         }
00023         catch( OfxhException& e )
00024         {
00025                 return e.getStatus();
00026         }
00027         catch(... )
00028         {
00029                 return kOfxStatErrUnknown;
00030         }
00031 }
00032 
00033 OfxStatus interactRedraw( OfxInteractHandle handle )
00034 {
00035         try
00036         {
00037                 interact::OfxhInteract* interactInstance = reinterpret_cast<interact::OfxhInteract*>( handle );
00038                 if( !interactInstance )
00039                         return kOfxStatErrBadHandle;
00040 
00041                 interactInstance->redraw();
00042 
00043                 return kOfxStatOK;
00044         }
00045         catch( OfxhException& e )
00046         {
00047                 return e.getStatus();
00048         }
00049         catch(... )
00050         {
00051                 return kOfxStatErrUnknown;
00052         }
00053 }
00054 
00055 OfxStatus interactGetPropertySet( OfxInteractHandle handle, OfxPropertySetHandle* property )
00056 {
00057         try
00058         {
00059                 interact::OfxhInteractBase* interact = reinterpret_cast<interact::OfxhInteractBase*>( handle );
00060                 if( !interact )
00061                         return kOfxStatErrBadHandle;
00062                 if( !interact->verifyMagic() )
00063                         return kOfxStatErrBadHandle;
00064 
00065                 *property = interact->getPropHandle();
00066 
00067                 return kOfxStatOK;
00068         }
00069         catch( OfxhException& e )
00070         {
00071                 return e.getStatus();
00072         }
00073         catch(... )
00074         {
00075                 return kOfxStatErrUnknown;
00076         }
00077 }
00078 
00079 /// the interact suite
00080 OfxInteractSuiteV1 gSuite = {
00081         interactSwapBuffers,
00082         interactRedraw,
00083         interactGetPropertySet
00084 };
00085 
00086 }
00087 
00088 /// function to get the interact suite
00089 void* getInteractSuite( const int version )
00090 {
00091         if( version == 1 )
00092                 return static_cast<void*>( &gSuite );
00093         return NULL;
00094 }
00095 
00096 }
00097 }
00098 }
00099 }
00100