OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
MakeDataSource.hpp
Go to the documentation of this file.
1 // -*- C++ -*-
2 /***************************************************************************
3  *
4  * The IPPL Framework
5  *
6  * This program was prepared by PSI.
7  * All rights in the program are reserved by PSI.
8  * Neither PSI nor the author(s)
9  * makes any warranty, express or implied, or assumes any liability or
10  * responsibility for the use of this software
11  *
12  * Visit www.amas.web.psi for more details
13  *
14  ***************************************************************************/
15 
16 // -*- C++ -*-
17 /***************************************************************************
18  *
19  * The IPPL Framework
20  *
21  *
22  * Visit http://people.web.psi.ch/adelmann/ for more details
23  *
24  ***************************************************************************/
25 
26 // include files
29 #include "DataSource/DataConnect.h"
30 
31 //
32 // include the connection-method-specific class headers
33 //
34 
35 // file connection method
39 
40 // forward declaration to avoid possible recursive inclusion
41 template<class T, unsigned Dim, class M, class C>
43 template<class T>
45 template<class T>
47 
49 // a version of make_DataSourceObject for Field's.
50 // arguments: name, connection type, transfer method, Field
51 template<class T, unsigned Dim, class M, class C>
53 make_DataSourceObject(const char *nm, DataConnect *dc, int t,
54  Field<T,Dim,M,C>& F) {
55 
56  // get the connection method name, and make a string out of it
57  std::string method(dc->DSID());
58 
59  // find what method it is, and make the appropriate DataSourceObject
60  DataSourceObject *dso = 0;
61  if (method == "file") {
62  // create a DataSourceObject for this Field which will connect to a file
63  dso = new FileFieldDataSource<T,Dim,M,C>(nm, dc, t, F);
64  }
65 
66  // make a default connection is nothing has been found
67  if (dso == 0)
68  dso = new DataSourceObject;
69 
70  return dso;
71 }
72 
73 
75 // a version of make_DataSourceObject for ParticleAttrib's
76 template<class T>
78 make_DataSourceObject(const char *nm, DataConnect *dc, int t,
79  ParticleAttrib<T>& P) {
80 
81  // get the connection method name, and make a string out of it
82  std::string method(dc->DSID());
83 
84  DataSourceObject *dso = 0;
85  if (method == "file") {
86  // create a DataSourceObject for this ParticleAttrib which will connect to
87  // a file
88  dso = new FileParticleAttribDataSource<T>(nm, dc, t, P);
89  }
90 
91  // make a default connection is nothing has been found
92  if (dso == 0)
93  dso = new DataSourceObject;
94 
95  return dso;
96 }
97 
98 
100 // a version of make_DataSourceObject for IpplParticleBase's
101 template<class PLayout>
103 make_DataSourceObject(const char *nm, DataConnect *dc, int t,
105 
106  // get the connection method name, and make a string out of it
107  std::string method(dc->DSID());
108 
109  DataSourceObject *dso = 0;
110  if (method == "file") {
111  // create a DataSourceObject for this FILE which will connect to
112  // a file
113  dso = new FileIpplParticleBaseDataSource<PLayout>(nm, dc, t, P);
114  }
115 
116  // make a default connection is nothing has been found
117  if (dso == 0)
118  dso = new DataSourceObject;
119 
120  return dso;
121 }
DataSourceObject * make_DataSourceObject(const char *nm, DataConnect *dc, int t, Field< T, Dim, M, C > &F)
const char * DSID() const
Definition: DataConnect.h:55