Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

src/DataSource/PtclBaseDataSource.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 /***************************************************************************
00003  *
00004  * The IPPL Framework
00005  * 
00006  *
00007  * Visit http://people.web.psi.ch/adelmann/ for more details
00008  *
00009  ***************************************************************************/
00010 
00011 #ifndef PARTICLE_BASE_DATA_SOURCE_H
00012 #define PARTICLE_BASE_DATA_SOURCE_H
00013 
00014 /***********************************************************************
00015  *
00016  * class ParticleBaseDataSource
00017  *
00018  * ParticleBaseDataSource is a base class which
00019  * stores a static list of all ParticleBaseDataSource's (stored as
00020  * ParticleBaseDataSource pointers) which are currently connected.  This
00021  * is needed so that ParticleAttrib's can determine if their parent
00022  * ParticleBase has been previously connected, and if so they can then
00023  * put themselves in the list for that ParticleBase as an attribute to be
00024  * transmitted along with the particle positions.  Subclasses provide
00025  * specific functionality to connect to external agencies such as viz
00026  * programs.
00027  *
00028  ***********************************************************************/
00029 
00030 // include files 
00031 #include "DataSource/DataSourceObject.h"
00032 
00033 #ifdef IPPL_STDSTL
00034 #include <vector>
00035 using std::vector;
00036 #else
00037 #include <vector.h>
00038 #endif // IPPL_STDSTL
00039 
00040 
00041 // forward declarations
00042 class ParticleAttribDataSource;
00043 class ParticleAttribBase;
00044 
00045 
00046 class ParticleBaseDataSource : public DataSourceObject {
00047 
00048 public:
00049   // some useful typedefs
00050   typedef vector<ParticleAttribDataSource *> AttribList_t;
00051   typedef vector<ParticleBaseDataSource *>   BaseList_t;
00052 
00053 public:
00054   // constructor: name, connection method, transfer method
00055   ParticleBaseDataSource(const char *, DataConnect *, int, DataSource *);
00056 
00057   // destructor
00058   virtual ~ParticleBaseDataSource();
00059 
00060   // get the begin/end iterators for the list of attributes
00061   AttribList_t::iterator begin_attrib() { return AttribList.begin(); }
00062   AttribList_t::iterator end_attrib()   { return AttribList.end(); }
00063 
00064   // return begin/end iterators for the list of particle base holders
00065   static BaseList_t::iterator begin_base() { return BaseList.begin(); }
00066   static BaseList_t::iterator end_base()   { return BaseList.end(); }
00067 
00068   // try to add a new ParticleAttrib (stored in a ParticleAttribDataSource
00069   // object) to our list of connected attributes.  This will check through
00070   // the list of registered ParticleBase's, and add it to the proper one.
00071   // If none are found, this returns NULL, otherwise this method returns
00072   // a pointer to the ParticleBaseDataSource to which the attrib was added.
00073   // This function is static, so that it may be called without a specific
00074   // ParticleBaseDataSource instance.
00075   static
00076   ParticleBaseDataSource* find_particle_base(ParticleAttribDataSource *,
00077                                              ParticleAttribBase *);
00078 
00079   //
00080   // ParticleBaseDataSource public virtual function interface
00081   //
00082 
00083   // make a connection using the given attribute.  Return success.
00084   virtual bool connect_attrib(ParticleAttribDataSource *);
00085 
00086   // disconnect from the external agency the connection involving this
00087   // particle base and the given attribute.  Return success.
00088   virtual bool disconnect_attrib(ParticleAttribDataSource *);
00089 
00090   // check to see if the given ParticleAttribBase is in this ParticleBase's
00091   // list of registered attributes.  Return true if this is so.
00092   virtual bool has_attrib(ParticleAttribBase *) = 0;
00093 
00094 protected:
00095   // register ourselves as a properly-connected ParticleBase holder.  This
00096   // should be called by the connect method in subclasses after a successful
00097   // checkin.
00098   void checkin();
00099 
00100   // unregister ourselves ... generally called by the disconnect method
00101   // of subclasses.
00102   void checkout();
00103 
00104 private:
00105   // a non-static list of the ParticleAttrib's which have been requested
00106   // to connect to the same receiver as this object's ParticleBase
00107   AttribList_t AttribList;
00108 
00109   // a static list of the currently-connected ParticleBaseDataSource's.
00110   static BaseList_t BaseList;
00111 };
00112 
00113 
00114 #endif // PARTICLE_BASE_DATA_SOURCE_H
00115 
00116 /***************************************************************************
00117  * $RCSfile: PtclBaseDataSource.h,v $   $Author: adelmann $
00118  * $Revision: 1.1.1.1 $   $Date: 2003/01/23 07:40:25 $
00119  * IPPL_VERSION_ID: $Id: PtclBaseDataSource.h,v 1.1.1.1 2003/01/23 07:40:25 adelmann Exp $ 
00120  ***************************************************************************/

Generated on Fri Nov 2 01:25:55 2007 for IPPL by doxygen 1.3.5