OPAL (Object Oriented Parallel Accelerator Library)  2.2.0
OPAL
PtclBaseDataSource.h
Go to the documentation of this file.
1 // -*- C++ -*-
2 /***************************************************************************
3  *
4  * The IPPL Framework
5  *
6  *
7  * Visit http://people.web.psi.ch/adelmann/ for more details
8  *
9  ***************************************************************************/
10 
11 #ifndef PARTICLE_BASE_DATA_SOURCE_H
12 #define PARTICLE_BASE_DATA_SOURCE_H
13 
14 /***********************************************************************
15  *
16  * class IpplParticleBaseDataSource
17  *
18  * IpplParticleBaseDataSource is a base class which
19  * stores a static list of all IpplParticleBaseDataSource's (stored as
20  * IpplParticleBaseDataSource pointers) which are currently connected. This
21  * is needed so that ParticleAttrib's can determine if their parent
22  * IpplParticleBase has been previously connected, and if so they can then
23  * put themselves in the list for that IpplParticleBase as an attribute to be
24  * transmitted along with the particle positions. Subclasses provide
25  * specific functionality to connect to external agencies such as viz
26  * programs.
27  *
28  ***********************************************************************/
29 
30 // include files
32 
33 #include <vector>
34 
35 // forward declarations
37 class ParticleAttribBase;
38 
39 
41 
42 public:
43  // some useful typedefs
44  typedef std::vector<ParticleAttribDataSource *> AttribList_t;
45  typedef std::vector<IpplParticleBaseDataSource *> BaseList_t;
46 
47 public:
48  // constructor: name, connection method, transfer method
49  IpplParticleBaseDataSource(const char *, DataConnect *, int, DataSource *);
50 
51  // destructor
53 
54  // get the begin/end iterators for the list of attributes
57 
58  // return begin/end iterators for the list of particle base holders
59  static BaseList_t::iterator begin_base() { return BaseList.begin(); }
60  static BaseList_t::iterator end_base() { return BaseList.end(); }
61 
62  // try to add a new ParticleAttrib (stored in a ParticleAttribDataSource
63  // object) to our list of connected attributes. This will check through
64  // the list of registered IpplParticleBase's, and add it to the proper one.
65  // If none are found, this returns NULL, otherwise this method returns
66  // a pointer to the IpplParticleBaseDataSource to which the attrib was added.
67  // This function is static, so that it may be called without a specific
68  // IpplParticleBaseDataSource instance.
69  static
72 
73  //
74  // IpplParticleBaseDataSource public virtual function interface
75  //
76 
77  // make a connection using the given attribute. Return success.
79 
80  // disconnect from the external agency the connection involving this
81  // particle base and the given attribute. Return success.
83 
84  // check to see if the given ParticleAttribBase is in this IpplParticleBase's
85  // list of registered attributes. Return true if this is so.
86  virtual bool has_attrib(ParticleAttribBase *) = 0;
87 
88 protected:
89  // register ourselves as a properly-connected IpplParticleBase holder. This
90  // should be called by the connect method in subclasses after a successful
91  // checkin.
92  void checkin();
93 
94  // unregister ourselves ... generally called by the disconnect method
95  // of subclasses.
96  void checkout();
97 
98 private:
99  // a non-static list of the ParticleAttrib's which have been requested
100  // to connect to the same receiver as this object's IpplParticleBase
102 
103  // a static list of the currently-connected IpplParticleBaseDataSource's.
105 };
106 
107 
108 #endif // PARTICLE_BASE_DATA_SOURCE_H
109 
110 /***************************************************************************
111  * $RCSfile: PtclBaseDataSource.h,v $ $Author: adelmann $
112  * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:25 $
113  * IPPL_VERSION_ID: $Id: PtclBaseDataSource.h,v 1.1.1.1 2003/01/23 07:40:25 adelmann Exp $
114  ***************************************************************************/
virtual bool disconnect_attrib(ParticleAttribDataSource *)
AttribList_t::iterator end_attrib()
std::vector< ParticleAttribDataSource * > AttribList_t
static IpplParticleBaseDataSource * find_particle_base(ParticleAttribDataSource *, ParticleAttribBase *)
IpplParticleBaseDataSource(const char *, DataConnect *, int, DataSource *)
virtual bool connect_attrib(ParticleAttribDataSource *)
std::vector< IpplParticleBaseDataSource * > BaseList_t
AttribList_t::iterator begin_attrib()
static BaseList_t::iterator begin_base()
virtual bool has_attrib(ParticleAttribBase *)=0
std::string::iterator iterator
Definition: MSLang.h:16
static BaseList_t::iterator end_base()