TIMPI
Loading...
Searching...
No Matches
data_type.h
Go to the documentation of this file.
1// The TIMPI Message-Passing Parallelism Library.
2// Copyright (C) 2002-2025 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3
4// This library is free software; you can redistribute it and/or
5// modify it under the terms of the GNU Lesser General Public
6// License as published by the Free Software Foundation; either
7// version 2.1 of the License, or (at your option) any later version.
8
9// This library is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// Lesser General Public License for more details.
13
14// You should have received a copy of the GNU Lesser General Public
15// License along with this library; if not, write to the Free Software
16// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17
18
19#ifndef TIMPI_DATA_TYPE_H
20#define TIMPI_DATA_TYPE_H
21
22// TIMPI includes
24
25namespace TIMPI
26{
27
28#ifdef TIMPI_HAVE_MPI
29//-------------------------------------------------------------------
34
35#else
36
37// These shouldn't actually be needed, but must be
38// unique types for function overloading to work
39// properly.
40struct data_type { /* unsigned int t; */ };
41
42#endif // TIMPI_HAVE_MPI
43
44
45
46//-------------------------------------------------------------------
51{
52public:
53 DataType () = default;
54 DataType (const DataType & other) = default;
55 DataType (DataType && other) = default;
56 static const bool is_fixed_type = true;
57
58 DataType (const data_type & type) :
59 _datatype(type)
60 {}
61
62 DataType (const DataType & other, unsigned int count)
63 {
64 // FIXME - if we nest an inner type here will we run into bug
65 // https://github.com/libMesh/libmesh/issues/631 again?
67 ignore(other, count); // ifndef TIMPI_HAVE_MPI
68 this->commit();
69 }
70
71 virtual ~DataType () = default;
72
73 DataType & operator = (const DataType & other) = default;
75
77 { _datatype = type; return *this; }
78
79 operator const data_type & () const
80 { return _datatype; }
81
82 operator data_type & ()
83 { return _datatype; }
84
85 // operator data_type const * () const
86 // { return &_datatype; }
87
88 // operator data_type * ()
89 // { return &_datatype; }
90
91 void commit ()
92 {
95 }
96
97 void free ()
98 {
101 }
102
103protected:
104
106};
107
121{
122public:
123 NotADataType () = default;
124 NotADataType (const NotADataType & other) = default;
126 ~NotADataType () = default;
129
130 static const bool is_fixed_type = false;
131};
132
133template <bool>
135 typedef DataType type;
136};
137
138template <>
140{
142};
143
144} // namespace TIMPI
145
146#endif // TIMPI_DATA_TYPE_H
Encapsulates the MPI_Datatype.
Definition data_type.h:51
DataType(const DataType &other, unsigned int count)
Definition data_type.h:62
data_type _datatype
Definition data_type.h:105
static const bool is_fixed_type
Definition data_type.h:56
DataType(const data_type &type)
Definition data_type.h:58
DataType()=default
virtual ~DataType()=default
DataType(const DataType &other)=default
DataType & operator=(const DataType &other)=default
DataType(DataType &&other)=default
StandardType<T>'s which do not define a way to MPI_Type T should inherit from this class.
Definition data_type.h:121
NotADataType(const NotADataType &other)=default
NotADataType(NotADataType &&other)=default
~NotADataType()=default
NotADataType()=default
NotADataType & operator=(const NotADataType &other)=default
static const bool is_fixed_type
Definition data_type.h:130
Tnew cast_int(Told oldvar)
void ignore(const Args &...)