message_tag.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 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 LIBMESH_MESSAGE_TAG_H
20 #define LIBMESH_MESSAGE_TAG_H
21 
22 // libMesh Includes
23 #include "libmesh/libmesh_common.h"
24 
25 // C++ includes
26 #include <climits> // INT_MIN
27 
28 namespace libMesh
29 {
30 
35 namespace Parallel
36 {
37 //-------------------------------------------------------------------
41 class Communicator;
42 
43 //-------------------------------------------------------------------
48 {
49 public:
50 
54  static const int invalid_tag = INT_MIN;
55 
60  explicit MessageTag(int tagvalue = invalid_tag)
61  : _tagvalue(tagvalue), _comm(nullptr) {}
62 
67  MessageTag(const MessageTag & other);
68 
73  MessageTag(MessageTag && other);
74 
79  MessageTag & operator = (const MessageTag & other);
80 
85  MessageTag & operator = (MessageTag && other);
86 
91  ~MessageTag();
92 
93  int value() const {
94  return _tagvalue;
95  }
96 
97 private:
98  int _tagvalue;
100 
101  // Constructor for reference-counted unique tags
102  MessageTag(int tagvalue, const Communicator * comm)
103  : _tagvalue(tagvalue), _comm(comm) {}
104 
105  // Let Communicator handle the reference counting
106  friend class Communicator;
107 };
108 
109 
110 //-------------------------------------------------------------------
114 #ifdef LIBMESH_HAVE_MPI
115 const MessageTag any_tag = MessageTag(MPI_ANY_TAG);
116 #else
117 const MessageTag any_tag = MessageTag(-1);
118 #endif
119 
121 
122 } // namespace Parallel
123 
124 } // namespace libMesh
125 
126 #endif // LIBMESH_MESSAGE_TAG_H
MessageTag(int tagvalue=invalid_tag)
Definition: message_tag.h:60
MessageTag(int tagvalue, const Communicator *comm)
Definition: message_tag.h:102
const MessageTag no_tag
Definition: message_tag.h:120
static const int invalid_tag
Definition: message_tag.h:54
const MessageTag any_tag
Definition: message_tag.h:115
MessageTag & operator=(const MessageTag &other)
Definition: message_tag.C:57
const Communicator * _comm
Definition: message_tag.h:99