Savarese Software Research Corporation
Message.h
Go to the documentation of this file.
1 /*
2  *
3  * Copyright 2006 Savarese Software Research Corporation
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.savarese.com/software/ApacheLicense-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
23 #ifndef __SSRC_SPREAD_MESSAGE_H
24 #define __SSRC_SPREAD_MESSAGE_H
25 
28 
30 
47 class Message : public BaseMessage, public detail::ByteBuffer {
48 protected:
49 
50 #ifdef LIBSSRCSPREAD_ENABLE_MEMBERSHIP_INFO
51 
52  virtual int sp_get_membership_info(Spread::membership_info *info) const {
53  return Spread::SP_get_memb_info(&(this->operator[](0)), service(), info);
54  }
55 
56  virtual int sp_get_vs_set_members(const Spread::vs_set_info *vs_set,
57  Spread::group_type member_names[],
58  unsigned int member_names_count)
59  const
60  {
61  return
62  Spread::SP_get_vs_set_members(&(this->operator[](0)),
63  vs_set, member_names, member_names_count);
64  }
65 
66  virtual int sp_get_vs_sets_info(Spread::vs_set_info *vs_sets,
67  unsigned int num_vs_sets,
68  unsigned int *index)
69  const
70  {
71  return
72  Spread::SP_get_vs_sets_info(&(this->operator[](0)),
73  vs_sets, num_vs_sets, index);
74  }
75 
76 #endif
77 
78 public:
79 
80  enum {
83  };
84 
93  explicit Message(const unsigned int capacity = DefaultCapacity) :
95 
96  virtual unsigned int size() const {
97  return detail::ByteBuffer::size();
98  }
99 
100  virtual void clear() {
101  return detail::ByteBuffer::clear();
102  }
103 
104 };
105 
107 
108 #endif
unsigned int capacity() const
Returns the maximum number of elements that can be written to the buffer without reallocating memory...
Definition: Buffer.h:86
unsigned int size() const
Returns the number of elements contained in the buffer.
Definition: Buffer.h:223
ByteBuffer(const unsigned int capacity)
Creates a buffer with the specified capacity and sets its size and offset to zero.
Definition: ByteBuffer.h:56
virtual void clear()
Clears the message for reuse, resetting its size to zero.
Definition: Message.h:100
Message(const unsigned int capacity=DefaultCapacity)
Creates a Message with the specified initial capacity (or DefaultCapacity if no parameter is provided...
Definition: Message.h:93
This header defines the ByteBuffer class.
This header defines the MembershipInfo class.
Message is a reusable and resizable data buffer for sending and receiving messages.
Definition: Message.h:47
BaseMessage is an abstract class defining the operations shared in common by Message and ScatterMessa...
Definition: BaseMessage.h:60
#define __BEGIN_NS_SSRC_SPREAD
virtual unsigned int size() const
Returns the number of bytes in the message.
Definition: Message.h:96
The default capacity used to construct a Message.
Definition: Message.h:82
service_type service() const
Returns the service type requested (for sends) or sent under (for receives) of the message...
Definition: BaseMessage.h:177
ByteBuffer provides the ability to write and read bytes to and from a buffer and reuse the buffer for...
Definition: ByteBuffer.h:43
#define __END_NS_SSRC_SPREAD
Definition: Buffer.h:31
__BEGIN_NS_SPREAD_INCLUDE typedef char group_type[MAX_GROUP_NAME]
This is an internal typedef not meant for use in end-user code.
Definition: GroupList.h:36
void clear()
Rewinds the read/write position befor resizing the buffer to zero.
Definition: ByteBuffer.h:119

Savarese Software Research Corporation
Copyright © 2006-2015 Savarese Software Research Corporation. All rights reserved.