TIMPI
Loading...
Searching...
No Matches
message_tag.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_MESSAGE_TAG_H
20#define TIMPI_MESSAGE_TAG_H
21
22// TIMPI Includes
23#include "timpi/timpi_config.h"
24
25// C/C++ includes
26#ifdef TIMPI_HAVE_MPI
28# include "mpi.h"
30#endif // TIMPI_HAVE_MPI
31
32#include <climits> // INT_MIN
33
34namespace TIMPI
35{
36//-------------------------------------------------------------------
40class Communicator;
41
42//-------------------------------------------------------------------
47{
48public:
49
53 static const int invalid_tag = INT_MIN;
54
61
67
73
79
85
91
92 int value() const {
93 return _tagvalue;
94 }
95
96private:
99
100 // Constructor for reference-counted unique tags
102 : _tagvalue(tagvalue), _comm(comm) {}
103
104 // Let Communicator handle the reference counting
105 friend class Communicator;
106};
107
108
109//-------------------------------------------------------------------
113#ifdef TIMPI_HAVE_MPI
115#else
116const MessageTag any_tag = MessageTag(-1);
117#endif
118
120
121} // namespace TIMPI
122
123#endif // TIMPI_MESSAGE_TAG_H
Encapsulates the MPI_Comm object.
Encapsulates the MPI tag integers.
Definition message_tag.h:47
const Communicator * _comm
Definition message_tag.h:98
int value() const
Definition message_tag.h:92
MessageTag(int tagvalue, const Communicator *comm)
MessageTag(int tagvalue=invalid_tag)
Explicit constructor, to discourage using "magic numbers" as tags.
Definition message_tag.h:59
static const int invalid_tag
Invalid tag, to allow for default construction.
Definition message_tag.h:53
~MessageTag()
Destructor.
Definition message_tag.C:32
MessageTag & operator=(const MessageTag &other)
Copy assignment operator.
Definition message_tag.C:55
const MessageTag any_tag
Default message tag ids.
Tnew cast_int(Told oldvar)
const MessageTag no_tag