OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
DataConnect.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 DATA_CONNECT_H
12#define DATA_CONNECT_H
13
14/***********************************************************************
15 *
16 * DataConnect is the base class for all objects which maintain a connection
17 * with another program or external agency. When constructed, it initializes
18 * and maintains the connection, and provides information for transferral
19 * of individual data objects such as Particles and Fields.
20 *
21 ***********************************************************************/
22
23// include files
25#include "Utility/NamedObj.h"
26
27// forward declarations
29
30
31
32class DataConnect : public NamedObj {
33
34public:
35 // typedef for our list of DataSource's
36 typedef std::vector<DataSource *> container_t;
38 typedef container_t::const_iterator const_iterator;
39
40public:
41 // constructor
42 DataConnect(const char *nm, const char *id, int dtm = DataSource::OUTPUT,
43 int n = 0);
44
45 // destructor
46 virtual ~DataConnect();
47
48 //
49 // informative methods
50 //
51
52 // return the ID for this object ... different types of DataConnect
53 // subclasses have different ID's
54 // ada change ID() to DSID() because of name clash
55 const char *DSID() const { return MyID.c_str(); }
56
57 // get or set our defalt data transfer method
60
61 // return the number of nodes that should be used for display
62 int getNodes() const { return nodes; }
63
64 // return true if our nodes is one of the connection nodes
65 bool onConnectNode() const;
66
67 //
68 // iterators for our list of registered objects
69 //
70
71 iterator begin() { return SourceList.begin(); }
72 iterator end() { return SourceList.end(); }
73
74 const_iterator begin() const { return SourceList.begin(); }
75 const_iterator end() const { return SourceList.end(); }
76
77 //
78 // other container-like routines
79 //
80
81 // return the number of registered DataSource's
82 unsigned int size() const { return SourceList.size(); }
83 unsigned int numDataSources() const { return SourceList.size(); }
84 bool empty() const { return SourceList.empty(); }
85
86 //
87 // DataConnect virtual methods, which all have default behavior
88 //
89
90 // are we currently connected to a receiver?
91 virtual bool connected() const;
92
93 // Register an object as something that can be a source of data.
94 // Arguments = name of item, DataSource object, and transfer method
95 // (INPUT, OUTPUT, BOTH, or DEFAULT). If this connection object is
96 // not actually connected, it is an error and this will return NULL.
97 // Otherwise, if the connection works, return the connection.
98 virtual DataConnect *connect(const char *, DataSource *,
100 virtual DataConnect *connect(const char *, DataSource &,
102
103 // Add a new single DataSourceObject connection. It is added to the
104 // DataSource's list of single connections, and the DataSource will
105 // end up being added to our list of known sources. Return success.
106 virtual bool connect(DataSourceObject *);
107
108 // perform update for all registered DataSource's. The optional
109 // argument can be used to just update all things connected to the
110 // current connector and any other connectors (if the pointer is 0),
111 // to just those things that are connected to the current connector
112 // AND are also connected to the provided connector.
113 virtual void updateConnections(DataConnect * = 0);
114
115 // disconnect all the registered DataSource's.
116 virtual void disconnectConnections();
117
118 // allow all connections to perform an interactive action. An optional
119 // command string can be supplied; if it is null, it will be ignored.
120 virtual void interact(const char * = 0, DataConnect * = 0);
121
122 // synchronization mechanism for waiting on some outside request.
123 virtual void ready();
124
125private:
126 friend class DataSource;
127
128 // ID for this object
129 std::string MyID;
130
131 // our list of connected data objects
133
134 // the number of nodes to connect with
135 int nodes;
136
137 // default transfer method
139
140 // Register a data object as connected here. Return success.
141 bool checkin(DataSource *);
142
143 // remove a data object from our connected list. Return success.
144 // Argument = whether we need to have the DataSource disconnect first.
145 bool checkout(DataSource *, bool = true);
146};
147
148#endif // DATA_CONNECT_H
149
150/***************************************************************************
151 * $RCSfile: DataConnect.h,v $ $Author: adelmann $
152 * $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:24 $
153 * IPPL_VERSION_ID: $Id: DataConnect.h,v 1.1.1.1 2003/01/23 07:40:24 adelmann Exp $
154 ***************************************************************************/
std::string::iterator iterator
Definition: MSLang.h:16
unsigned int size() const
Definition: DataConnect.h:82
iterator end()
Definition: DataConnect.h:72
bool checkin(DataSource *)
const_iterator end() const
Definition: DataConnect.h:75
virtual void ready()
bool checkout(DataSource *, bool=true)
virtual bool connected() const
Definition: DataConnect.cpp:63
virtual void updateConnections(DataConnect *=0)
container_t::const_iterator const_iterator
Definition: DataConnect.h:38
int getNodes() const
Definition: DataConnect.h:62
std::string MyID
Definition: DataConnect.h:129
const char * DSID() const
Definition: DataConnect.h:55
container_t::iterator iterator
Definition: DataConnect.h:37
iterator begin()
Definition: DataConnect.h:71
int DefTransMethod
Definition: DataConnect.h:138
container_t SourceList
Definition: DataConnect.h:132
bool onConnectNode() const
Definition: DataConnect.cpp:55
bool empty() const
Definition: DataConnect.h:84
int getDefaultTransferMethod() const
Definition: DataConnect.h:58
virtual DataConnect * connect(const char *, DataSource *, int=DataSource::DEFAULT)
Definition: DataConnect.cpp:74
virtual ~DataConnect()
Definition: DataConnect.cpp:47
unsigned int numDataSources() const
Definition: DataConnect.h:83
void setDefaultTransferMethod(int m)
Definition: DataConnect.h:59
virtual void interact(const char *=0, DataConnect *=0)
DataConnect(const char *nm, const char *id, int dtm=DataSource::OUTPUT, int n=0)
Definition: DataConnect.cpp:37
std::vector< DataSource * > container_t
Definition: DataConnect.h:36
virtual void disconnectConnections()
const_iterator begin() const
Definition: DataConnect.h:74