Main Page | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Namespace Members | Data Fields | Globals

PFParticle.h

Go to the documentation of this file.
00001 /* Copyright (C) 2005 Pierre Moisan (Pierre.Moisan@USherbrooke.ca) 
00002 
00003    This library is free software; you can redistribute it and/or
00004    modify it under the terms of the GNU Lesser General Public
00005    License as published by the Free Software Foundation; either
00006    version 2.1 of the License, or (at your option) any later version.
00007    
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Lesser General Public License for more details.
00012    
00013    You should have received a copy of the GNU Lesser General Public
00014    License along with this library; if not, write to the Free Software
00015    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00016 */
00017 
00018 #ifndef _PFPARTICLE_H_
00019 #define _PFPARTICLE_H_
00020 
00021 #include "Object.h"
00022 #include <iostream>
00023 
00024 namespace RobotFlow {
00025 
00026 typedef enum
00027 {
00028         e_PFP_Generic = 0,
00029         e_PFP_Unknown
00030 } e_PFP_type;
00031 
00032 //
00033 // This should be an abstract base class. Since many containers (like Vector)
00034 // do not allow abstract functions, each abstract function throws an exception
00035 // to avoid the direct use of the base class "abstract" routines.
00036 //
00037 class PFParticle : public FD::Object
00038 {
00039         friend std::ostream &operator<<(std::ostream &o_out, const PFParticle &i_ref)
00040         {
00041                 try {
00042                         i_ref.printOn(o_out);
00043                         // Enable cascading
00044                         return o_out;
00045                 }
00046                 catch (FD::BaseException *e) {
00047                         throw e->add(new FD::GeneralException("Exception in PFParticle::operator<<:",__FILE__,__LINE__));
00048                 }
00049         }
00050         
00051         friend std::istream &operator>>(std::istream &i_in, PFParticle &o_ref)
00052         {
00053                 try {
00054                         o_ref.readFrom(i_in);
00055                         // Enable cascading
00056                         return i_in;
00057                 }
00058                 catch (FD::BaseException *e) {
00059                         throw e->add(new FD::GeneralException("Exception in PFParticle::operator>>:",__FILE__,__LINE__));
00060                 }
00061         }
00062         
00063 public:
00064         PFParticle()
00065         : m_pfpType(e_PFP_Unknown)
00066         { 
00067         }
00068         
00069         PFParticle(e_PFP_type i_pfpType) 
00070         : m_pfpType(i_pfpType)
00071         { 
00072         }
00073         
00074         PFParticle(const PFParticle &i_ref) 
00075         { 
00076                 m_pfpType = i_ref.m_pfpType;
00077         }
00078 
00079         virtual ~PFParticle()
00080         {
00081         
00082         }
00083 
00084         virtual PFParticle & operator =(const PFParticle &i_ref)
00085         {
00086                 // Avoid self assignment
00087                 if (&i_ref != this) {
00088                         this->m_pfpType = i_ref.m_pfpType;
00089                 }
00090                 
00091                 return *this;
00092         }
00093         
00094         virtual PFParticle* clone()  const
00095         {
00096                 return new PFParticle(*this);
00097         }
00098 
00099         // Default routine to print a PFParticle object to an output stream
00100         virtual void printOn(std::ostream &out) const
00101         {
00102                 throw new FD::GeneralException("Exception in PFParticle::printOn: cannot use base class routine.",__FILE__,__LINE__);
00103         }
00104 
00105         // Default routine to read a PFParticle object from an input stream
00106         virtual void readFrom(std::istream &in)
00107         {
00108                 throw new FD::GeneralException("Exception in PFParticle::readFrom: cannot use base class routine.",__FILE__,__LINE__);
00109         }
00110         
00111         e_PFP_type GetType() const 
00112         { 
00113                 return m_pfpType; 
00114         }
00115         
00116         void SetType(e_PFP_type i_type)
00117         { 
00118                 m_pfpType = i_type; 
00119         }
00120         
00121         virtual unsigned int GetStateSize() const
00122         {
00123                 throw new FD::GeneralException("Exception in PFParticle::GetStateSize: cannot use base class routine.",__FILE__,__LINE__);
00124         }
00125         
00126         virtual float *GetState()
00127         {
00128                 throw new FD::GeneralException("Exception in PFParticle::GetState: cannot use base class routine.",__FILE__,__LINE__);
00129         }
00130         
00131         virtual const float *GetCstState() const 
00132         {
00133                 throw new FD::GeneralException("Exception in PFParticle::GetCstState: cannot use base class routine.",__FILE__,__LINE__);
00134         }
00135         
00136         virtual float GetStateIdx(int i_idx) const
00137         {
00138                 throw new FD::GeneralException("Exception in PFParticle::GetStateIdx: cannot use base class routine.",__FILE__,__LINE__);
00139         }
00140         
00141         virtual float GetWeight() const
00142         {
00143                 throw new FD::GeneralException("Exception in PFParticle::GetWeight: cannot use base class routine.",__FILE__,__LINE__);
00144         }
00145         
00146         virtual void SetStateSize(unsigned int i_size) 
00147         {
00148                 throw new FD::GeneralException("Exception in PFParticle::SetStateSize: cannot use base class routine.",__FILE__,__LINE__);
00149         }
00150         
00151         virtual void SetState(const float *i_state) 
00152         {
00153                 throw new FD::GeneralException("Exception in PFParticle::SetState: cannot use base class routine.",__FILE__,__LINE__);
00154         }
00155         
00156         virtual void SetStateIdx(int i_idx, float i_val)
00157         {
00158                 throw new FD::GeneralException("Exception in PFParticle::SetStateIdx: cannot use base class routine.",__FILE__,__LINE__);
00159         }
00160         
00161         virtual void SetWeight(float i_weight) 
00162         {
00163                 throw new FD::GeneralException("Exception in PFParticle::SetWeight: cannot use base class routine.",__FILE__,__LINE__);
00164         }
00165 
00166 private:
00167         e_PFP_type m_pfpType;
00168 };
00169 
00170 }
00171 
00172 #endif

Generated on Wed Oct 5 14:36:12 2005 for RobotFlow by  doxygen 1.4.4