Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

callout_Filter.cpp

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------
00002     Phission :
00003         Realtime Vision Processing System
00004 
00005     Copyright (C) 2003-2006 Philip D.S. Thoren (pthoren@cs.uml.edu)
00006     University of Massachusetts at Lowell,
00007     Laboratory for Artificial Intelligence and Robotics
00008 
00009  ---------------------------------------------------------------------------
00010     <Add other copyrights here> 
00011  ---------------------------------------------------------------------------
00012 
00013     This file is part of Phission.
00014 
00015     Phission is free software; you can redistribute it and/or modify
00016     it under the terms of the GNU Lesser General Public License as published by
00017     the Free Software Foundation; either version 2 of the License, or
00018     (at your option) any later version.
00019 
00020     Phission is distributed in the hope that it will be useful,
00021     but WITHOUT ANY WARRANTY; without even the implied warranty of
00022     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00023     GNU Lesser General Public License for more details.
00024 
00025     You should have received a copy of the GNU Lesser General Public License
00026     along with Phission; if not, write to the Free Software
00027     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028 
00029  ---------------------------------------------------------------------------*/
00030 #ifdef HAVE_CONFIG_H
00031     #include <phissionconfig.h>
00032 #endif
00033 
00034 #include <phStandard.h>
00035 
00036 #include <callout_Filter.h>
00037 
00038 #include <phError.h>
00039 #include <phMemory.h>
00040 #include <phPrint.h>
00041 
00042 /* ---------------------------------------------------------------------- */
00043 /* ( int value) */
00044 /* ---------------------------------------------------------------------- */
00045 callout_Filter::callout_Filter( ph_callout_fn    callout, 
00046                                 void            *userdata,
00047                                 uint32_t         supported_formats ) :
00048     phFilter("callout_Filter")
00049 
00050 {
00051     this->set(callout,userdata,supported_formats);
00052 }
00053 
00054 /* ---------------------------------------------------------------------- */
00055 callout_Filter::~callout_Filter()
00056 {
00057 }
00058 
00059 /* ------------------------------------------------------------------------ */
00060 phFilter *callout_Filter::cloneFilter()
00061 {
00062     phFUNCTION("callout_Filter::cloneFilter")
00063     int locked = 0;
00064     callout_Filter *callout = new callout_Filter();
00065     
00066     phTHIS_LOOSE_LOCK(locked);
00067     
00068     callout->set(this->m_callout,
00069                  this->m_data,
00070                  this->m_format);
00071 
00072     phTHIS_LOOSE_UNLOCK(locked);
00073 
00074     return (phFilter *)callout;
00075 }
00076 
00077 /* ---------------------------------------------------------------------- */
00078 int callout_Filter::set(ph_callout_fn callout, 
00079                         void         *userdata,
00080                         uint32_t      supported_formats)
00081 {
00082     phFUNCTION("callout_Filter::set")
00083     int locked = 0;
00084 
00085     /* LOOSE locking means that if it fails it won't adjust 'locked' and
00086      * it will continue with the main body of this method */
00087     phTHIS_LOOSE_LOCK(locked);
00088     
00089     this->m_callout = callout;
00090     this->m_data    = userdata;
00091     this->m_format  = supported_formats;
00092 
00093     phTHIS_LOOSE_UNLOCK(locked);
00094     
00095     return phSUCCESS;
00096 }
00097 
00098 /* ---------------------------------------------------------------------- */
00099 int callout_Filter::setCallout( ph_callout_fn callout )
00100 {
00101     phFUNCTION("callout_Filter::setCallout")
00102     int locked = 0;
00103 
00104     phTHIS_LOOSE_LOCK(locked);
00105     
00106     this->m_callout    = callout;
00107 
00108     phTHIS_LOOSE_UNLOCK(locked);
00109     
00110     return phSUCCESS;
00111 }
00112 
00113 /* ---------------------------------------------------------------------- */
00114 int callout_Filter::setUserData( void *userdata )
00115 {
00116     phFUNCTION("callout_Filter::setUserData")
00117     int locked = 0;
00118 
00119     phTHIS_LOOSE_LOCK(locked);
00120     
00121     this->m_data        = userdata;
00122 
00123     phTHIS_LOOSE_UNLOCK(locked);
00124     
00125     return phSUCCESS;
00126 }
00127 
00128 /* ---------------------------------------------------------------------- */
00129 int callout_Filter::setSuppportedFormats( uint32_t supported_formats )
00130 {
00131     phFUNCTION("callout_Filter::setSuppportedFormats")
00132     int locked = 0;
00133 
00134     phTHIS_LOOSE_LOCK(locked);
00135     
00136     this->m_format      = supported_formats;
00137 
00138     phTHIS_LOOSE_UNLOCK(locked);
00139     
00140     return phSUCCESS;
00141 }
00142 
00143 /* ---------------------------------------------------------------------- */
00144 int callout_Filter::filter()
00145 {
00146     phFUNCTION("callout_Filter::filter")
00147    
00148     /* defined before being called:
00149      *  width
00150      *  height
00151      *  depth
00152      *  Image
00153      */
00154     
00155     /* Begin Filter */
00156 
00157     if (this->m_callout != NULL)
00158     {
00159         rc = this->m_callout(this,this->m_workspaceImage,this->m_data);
00160         phCHECK_RC(rc,NULL,"User's callout function returned an error");
00161     }
00162     
00163     /* End Filter */
00164     
00165     /* make sure to free up any space here, not including Image */
00166     
00167     return phSUCCESS;
00168     
00169 /* Comment this back in if you use any macros that jump to here, ie phCHECK_RC,
00170  * or phCHECK_PTR */
00171 
00172 error:
00173     /* make sure to free up any space here, not including Image */
00174     
00175     return phFAIL;
00176 }
00177 
00178 




Copyright (C) 2002 - 2007 Philip D.S. Thoren ( pthoren@users.sourceforge.net )
University Of Massachusetts at Lowell
Robotics Lab
SourceForge.net Logo

Generated on Sat Jun 16 02:44:09 2007 for phission by  doxygen 1.4.4