OutControl.cxx

Go to the documentation of this file.
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 "OutControl.hxx"
00023 #include "InControl.hxx"
00024 #include "Processing.hxx"
00025 
00026 namespace CLAM {
00027 
00028 // Creation/Destruction
00029 
00030 OutControl::OutControl(const std::string& name, Processing* parent, const bool publish) :
00031         mName(name), mParent(parent)
00032 {
00033         if (parent && publish)  parent->RegisterOutControl(this);
00034 }
00035                 
00036 OutControl::~OutControl()
00037 {
00038         while (!mLinks.empty())
00039                 RemoveLink(*mLinks.front());
00040 
00041         if (mParent)
00042                 mParent->GetOutControls().ProcessingInterface_Unregister(this);
00043 }
00044 // Methods
00045 
00046 std::list<InControl*>::iterator OutControl::BeginInControlsConnected()
00047 {
00048         return mLinks.begin();
00049 }
00050 
00051 std::list<InControl*>::iterator OutControl::EndInControlsConnected()
00052 {
00053         return mLinks.end();
00054 }
00055 
00056 
00057 
00058 void OutControl::AddLink(InControl& in)
00059 {
00060         mLinks.push_back(&in);
00061         in.OutControlInterface_AddLink(*this);
00062 }
00063 void OutControl::RemoveLink(InControl& in)
00064 {
00065         mLinks.remove( &in );
00066         in.OutControlInterface_RemoveLink(*this);
00067 }
00068 int OutControl::SendControl(TControlData val)
00069 {
00070         int ret=0;
00071         std::list<InControl*>::iterator it;
00072         for (it=mLinks.begin(); it!=mLinks.end(); it++) 
00073         {
00074                 ret = (*it)->DoControl(val);
00075         }
00076         // TODO: depracate controls with return value.
00077         return ret;
00078 }
00079 
00080 bool OutControl::IsConnected()
00081 {
00082         return ! mLinks.empty();
00083 }
00084 
00085 bool OutControl::IsConnectedTo( InControl & in)
00086 {
00087         std::list<InControl*>::iterator it;
00088         for (it=mLinks.begin(); it!=mLinks.end(); it++) 
00089                 if ((*it) == &in)
00090                         return true;
00091 
00092         return false;
00093 }
00094 
00095 
00096 
00097 
00098 }; //namespace CLAM
00099 

Generated on Tue Aug 12 22:33:43 2008 for CLAM by  doxygen 1.5.5