File: multi_message_slab.cpp

package info (click to toggle)
esys-particle 2.3.4%2Bdfsg1-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 13,036 kB
  • ctags: 10,805
  • sloc: cpp: 80,009; python: 5,872; makefile: 1,243; sh: 313; perl: 225
file content (148 lines) | stat: -rw-r--r-- 2,957 bytes parent folder | download
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/////////////////////////////////////////////////////////////
//                                                         //
// Copyright (c) 2003-2014 by The University of Queensland //
// Centre for Geoscience Computing                         //
// http://earth.uq.edu.au/centre-geoscience-computing      //
//                                                         //
// Primary Business: Brisbane, Queensland, Australia       //
// Licensed under the Open Software License version 3.0    //
// http://www.apache.org/licenses/LICENSE-2.0          //
//                                                         //
/////////////////////////////////////////////////////////////


#include "tml/message/multi_message_slab.h"
#include "tml/message/packed_multi_message.h"

/*!
  construct TML_PackedMultiMessageSlab

  \param msg the multimessage to which the slab belongs
  \param idx the index 
*/
TML_PackedMultiMessageSlab::TML_PackedMultiMessageSlab(TML_PackedMultiMessage* msg,int idx)
{
  m_msg=msg;
  m_idx=idx;
}

/*!
  reset the packing pointer
*/
void TML_PackedMultiMessageSlab::begin_pack()
{
  m_msg->begin_pack(m_idx);
}

/*!
  reset the unpacking pointer
*/
void TML_PackedMultiMessageSlab::begin_unpack()
{
  m_msg->begin_unpack(m_idx);
}
  
/*!
  pack integer into the slab

  \param i the interger
*/
void TML_PackedMultiMessageSlab::append(int i)
{
  m_msg->append(i,m_idx);
}
 
/*!
  pack a double into the slab

  \param d the double
*/
void TML_PackedMultiMessageSlab::append(double d)
{
  m_msg->append(d,m_idx);
}

/*!
  pack a STL string into the slab

  \param s the string
*/
void TML_PackedMultiMessageSlab::append(const string& s)
{
  m_msg->append(s,m_idx);
}

/*!
  Append a Vec3 to the message buffer. Calls append(double) per element
*/
void TML_PackedMultiMessageSlab::append(const Vec3& v)
{
  m_msg->append(v[0],m_idx);
  m_msg->append(v[1],m_idx);
  m_msg->append(v[2],m_idx);
}

/*!
  pack a booleam value into the slab

  \param b the boolean value
*/
void TML_PackedMultiMessageSlab::append(bool b)
{
  m_msg->append(b,m_idx);
}

/*!
  pop an int from the slab
*/
int TML_PackedMultiMessageSlab::pop_int()
{
  return m_msg->pop_int(m_idx);
}

/*!
  pop a double from the slab
*/
double TML_PackedMultiMessageSlab::pop_double()
{
  return m_msg->pop_double(m_idx);
}

/*!
  pop an array of doubles from the slab
  \warning not implemented
*/
void TML_PackedMultiMessageSlab::pop_doubles(double*,int)
{}

/*!
  pop a STL string  from the slab
  \warning not implemented
*/
string TML_PackedMultiMessageSlab::pop_string()
{
  string s;
  return s;
}

/*!
  Pop a Vec3 of the buffer. Calls pop_double per element
*/
Vec3 TML_PackedMultiMessageSlab::pop_vec3()
{
  Vec3 res;

  res[0]=m_msg->pop_double(m_idx);
  res[1]=m_msg->pop_double(m_idx);
  res[2]=m_msg->pop_double(m_idx);

  return res;
}

/*!
  pop a boolean value from the slab
*/
bool TML_PackedMultiMessageSlab::pop_bool()
{
  return m_msg->pop_bool(m_idx);
}