TuttleOFX
1
|
00001 /* 00002 * Software License : 00003 * 00004 * Copyright (c) 2007-2009, The Open Effects Association Ltd. All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions are met: 00008 * 00009 * Redistributions of source code must retain the above copyright notice, 00010 * this list of conditions and the following disclaimer. 00011 * Redistributions in binary form must reproduce the above copyright notice, 00012 * this list of conditions and the following disclaimer in the documentation 00013 * and/or other materials provided with the distribution. 00014 * Neither the name The Open Effects Association Ltd, nor the names of its 00015 * contributors may be used to endorse or promote products derived from this 00016 * software without specific prior written permission. 00017 * 00018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 00019 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00020 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00021 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 00022 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00023 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00024 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 00025 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00026 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00027 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00028 */ 00029 00030 // ofx host 00031 #include "OfxhProperty.hpp" 00032 #include "OfxhGetHook.hpp" 00033 #include "OfxhNotifyHook.hpp" 00034 00035 #include <tuttle/host/ofx/OfxhCore.hpp> 00036 #include <tuttle/host/exceptions.hpp> 00037 #include <tuttle/host/serialization.hpp> 00038 00039 // ofx 00040 #include <ofxImageEffect.h> 00041 00042 #include <boost/algorithm/string/join.hpp> 00043 00044 #include <iostream> 00045 #include <cstring> 00046 00047 //#define DEBUG_PROPERTIES true 00048 00049 namespace tuttle { 00050 namespace host { 00051 namespace ofx { 00052 namespace property { 00053 00054 OfxhProperty::OfxhProperty( const std::string& name, 00055 EPropType type, 00056 std::size_t dimension, 00057 bool pluginReadOnly ) 00058 : _name( name ) 00059 , _type( type ) 00060 , _dimension( dimension ) 00061 , _pluginReadOnly( pluginReadOnly ) 00062 , _modifiedBy( eModifiedByHost ) 00063 , _getHook( NULL ) 00064 {} 00065 00066 OfxhProperty::OfxhProperty( const OfxhProperty& other ) 00067 : _name( other._name ) 00068 , _type( other._type ) 00069 , _dimension( other._dimension ) 00070 , _pluginReadOnly( other._pluginReadOnly ) 00071 , _modifiedBy( other._modifiedBy ) 00072 , _getHook( NULL ) 00073 {} 00074 00075 OfxhProperty::~OfxhProperty() 00076 {} 00077 00078 /// call notify on the contained notify hooks 00079 void OfxhProperty::notify( bool single, int indexOrN ) 00080 { 00081 std::vector<OfxhNotifyHook*>::iterator i; 00082 for( i = _notifyHooks.begin(); i != _notifyHooks.end(); ++i ) 00083 { 00084 ( *i )->notify( _name, single, indexOrN ); 00085 } 00086 } 00087 00088 std::vector<std::string> OfxhProperty::getStringValues() const 00089 { 00090 std::vector<std::string> res; 00091 for( unsigned int i = 0; i < getDimension(); ++i ) 00092 res.push_back(getStringValueAt(i)); 00093 return res; 00094 } 00095 00096 /// get a string representing all the values of this property 00097 std::string OfxhProperty::getStringValue() const 00098 { 00099 if( getDimension() == 1 ) 00100 return getStringValueAt(0); 00101 if( getDimension() == 0 ) 00102 return ""; 00103 return boost::algorithm::join(getStringValues(), ", "); 00104 } 00105 00106 } 00107 } 00108 } 00109 }