-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmsg_pXold.h
More file actions
78 lines (63 loc) · 2.71 KB
/
msg_pXold.h
File metadata and controls
78 lines (63 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef __msg_p__H
#define __msg_p__H
#include <typeinfo>
#include <map>
#include <vector>
#include <string>
using namespace std;
//==============================================================================
class Msg_p {
public : typedef unsigned char byte; // Keep it simple
// Empty constructor
public : Msg_p();
// From received message
public : Msg_p(byte *,int);
public : virtual ~ Msg_p(void);
private: template <class T> void AddToMap();
private: template <class T> void Destroy();
public : void Dump();
private: template <class T> void Dump();
public : template <class T> T * Get(int,int &);
public : int Length();
private: template <class Z> Z pull(int=1);
private: template <class Z> void push(vector<byte> &,Z);
public : template <class T> void Put(int,T *,int=1);
public : byte * Stream();
public : void Tag(int);
public : int Tag();
private: template <class Z> Z pullB();
private: template <class Z> Z * copyB(int);
private: template <class Z> void pushB(vector<byte> &,Z);
private:
template <class T> struct SS { // One of these for each stored data item
SS():p(0),c(0),a(0){}
Wipe(){ delete [] p; p=0; delete [] a; a=0;}
T * p; // Copy of typed data
int c; // Count of them
int bc; // Count of bytes
byte * a; // Bit copy of data (i.e. p) as bytes
};
struct typemap { // One of these for each stored type
typemap(byte t0):typelen(t0){}
// typemap(byte t0,int t1):typelen(t0),typeint(t1){}
byte typelen; // Length of this type in bytes
// int typeint; // Each type has an integer ID
map <int,void *> Dmap;
};
//map <const char *,typemap *> Tmap; // Main sheetanchor map
map <int, typemap *> Tmap;
vector<byte> vm; // Packed output message
int typecount;
map <const char *,int> s2iMap; // Typename -> integer ID
map <int,const char *> i2sMap; // Integer ID -> typename
int tag; // MPI message tag
const static int EOM = -1; // End of message marker
friend bool operator == (Msg_p &,Msg_p &);
friend bool operator != (Msg_p &,Msg_p &);
};
//==============================================================================
bool operator == (Msg_p &,Msg_p &);
bool operator != (Msg_p &,Msg_p &);
//==============================================================================
#include "msg_p.tpp"
#endif