OPAL (Object Oriented Parallel Accelerator Library)  2021.1.99
OPAL
Format.h
Go to the documentation of this file.
1 //
2 // Class Format
3 // Format class to allow serializing message objects into plain buffers
4 // to send directly with mpi calls or similar means
5 //
6 // Copyright (c) 2008 - 2020, Paul Scherrer Institut, Villigen PSI, Switzerland
7 // All rights reserved
8 //
9 // This file is part of OPAL.
10 //
11 // OPAL is free software: you can redistribute it and/or modify
12 // it under the terms of the GNU General Public License as published by
13 // the Free Software Foundation, either version 3 of the License, or
14 // (at your option) any later version.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with OPAL. If not, see <https://www.gnu.org/licenses/>.
18 //
19 #ifndef FORMATTER_H
20 #define FORMATTER_H
21 
22 #include <algorithm>
23 #include <cstring>
24 #include <vector>
25 #include "Message/Message.h"
26 
27 class Format {
28 public:
29  Format(Message*);
30  unsigned int getItemCount() {
31  return items;
32  }
33  unsigned int getSize() {
34  return size;
35  }
36  unsigned int getFormatSize() {
37  return 2 * items * sizeof(int);
38  }
39  unsigned int getItemElems(int i) {
40  return format_array[2 * i + 0];
41  }
42  unsigned int getItemBytes(int i) {
43  return format_array[2 * i + 1];
44  }
45 
46  void print();
47 
48 private:
49  unsigned int items, size;
50  std::vector<unsigned int> format_array;
51 };
52 
53 #endif
Definition: Format.h:27
Format(Message *)
Definition: Format.cpp:21
unsigned int getItemBytes(int i)
Definition: Format.h:42
unsigned int size
Definition: Format.h:49
unsigned int items
Definition: Format.h:49
unsigned int getSize()
Definition: Format.h:33
unsigned int getItemCount()
Definition: Format.h:30
unsigned int getFormatSize()
Definition: Format.h:36
void print()
Definition: Format.cpp:36
std::vector< unsigned int > format_array
Definition: Format.h:50
unsigned int getItemElems(int i)
Definition: Format.h:39