Apache Qpid - AMQP Messaging for Java JMS, C++, Python, Ruby, and .NET Apache Qpid Documentation
SequenceNumber.h
Go to the documentation of this file.
1 /*
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements. See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership. The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License. You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied. See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  */
21 #ifndef _framing_SequenceNumber_h
22 #define _framing_SequenceNumber_h
23 
25 #include <boost/operators.hpp>
26 #include <iosfwd>
28 
29 namespace qpid {
30 namespace framing {
31 
32 class Buffer;
33 
38 boost::equality_comparable<
39  SequenceNumber, boost::less_than_comparable<
40  SequenceNumber, boost::incrementable<
41  SequenceNumber, boost::decrementable<SequenceNumber> > > >
42 {
43  int32_t value;
44 
45  public:
46  SequenceNumber(uint32_t v=0) : value(v) {}
47 
48  SequenceNumber& operator++() { ++value; return *this; }
49  SequenceNumber& operator--() { --value; return *this; }
50  bool operator==(const SequenceNumber& other) const { return value == other.value; }
51  bool operator<(const SequenceNumber& other) const { return (value - other.value) < 0; }
52  uint32_t getValue() const { return uint32_t(value); }
53  operator uint32_t() const { return uint32_t(value); }
54 
55  QPID_COMMON_EXTERN void encode(Buffer& buffer) const;
56  QPID_COMMON_EXTERN void decode(Buffer& buffer);
57  QPID_COMMON_EXTERN uint32_t encodedSize() const;
58 
59  template <class S> void serialize(S& s) { s(value); }
60 };
61 
62 inline int32_t operator-(const SequenceNumber& a, const SequenceNumber& b) {
63  return int32_t(a.getValue() - b.getValue());
64 }
65 
67  return SequenceNumber(a.getValue() + n);
68 }
69 
71  return SequenceNumber(a.getValue() - n);
72 }
73 
74 struct Window
75 {
78 };
79 
80 QPID_COMMON_EXTERN std::ostream& operator<<(std::ostream& o, const SequenceNumber& n);
81 
82 }} // namespace qpid::framing
83 
84 
85 #endif

Qpid C++ API Reference
Generated on Tue Mar 5 2013 for Qpid C++ Client API by doxygen 1.8.1.1