00001 /* 00002 * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG) 00003 * UNIVERSITAT POMPEU FABRA 00004 * 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License 00017 * along with this program; if not, write to the Free Software 00018 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00019 * 00020 */ 00021 00022 #include "InControl.hxx" 00023 #include "OutControl.hxx" 00024 #include "Processing.hxx" 00025 00026 namespace CLAM 00027 { 00028 00029 InControl::InControl(const std::string &name, Processing* parent, const bool publish) 00030 : mLastValue(0) 00031 , mName(name) 00032 , mParent(parent) 00033 , mUpperBound(1) 00034 , mLowerBound(0) 00035 , mBounded(false) 00036 , mHasDefaultValue(false) 00037 00038 { 00039 if (parent && publish) parent->RegisterInControl(this); 00040 } 00041 00042 00043 InControl::~InControl() 00044 { 00045 while (!mLinks.empty()) 00046 mLinks.front()->RemoveLink(*this); 00047 00048 if (mParent) 00049 mParent->GetInControls().ProcessingInterface_Unregister(this); 00050 } 00051 00052 bool InControl::IsConnectedTo( OutControl & out) 00053 { 00054 return out.IsConnectedTo( *this ); 00055 } 00056 00057 bool InControl::IsConnected() const 00058 { 00059 return !mLinks.empty(); 00060 } 00061 00062 bool InControl::IsBounded() const 00063 { 00064 return mBounded; 00065 } 00066 TControlData InControl::UpperBound() const 00067 { 00068 return mUpperBound; 00069 } 00070 TControlData InControl::LowerBound() const 00071 { 00072 return mLowerBound; 00073 } 00074 void InControl::SetBounds( TControlData lower, TControlData upper ) 00075 { 00076 mLowerBound = lower; 00077 mUpperBound = upper; 00078 mBounded = true; 00079 } 00080 void InControl::SetDefaultValue( TControlData val ) 00081 { 00082 mDefaultValue = val; 00083 mHasDefaultValue = true; 00084 } 00085 TControlData InControl::DefaultValue() const 00086 { 00087 if (mHasDefaultValue) return mDefaultValue; 00088 return (mUpperBound+mLowerBound)/2.f; 00089 } 00090 00091 void InControl::OutControlInterface_AddLink(OutControl & outControl) 00092 { 00093 mLinks.push_back(&outControl); 00094 } 00095 00096 void InControl::OutControlInterface_RemoveLink(OutControl & outControl) 00097 { 00098 mLinks.remove(&outControl); 00099 } 00100 00101 00102 }; // namespace CLAM 00103