NetLink Sockets C++  1.0.0
Networking C++ Library
 All Classes Namespaces Files Functions Enumerations Enumerator Pages
socket_group.inline.h
1 /*
2  NetLink Sockets: Networking C++ library
3  Copyright 2012 Pedro Francisco Pareja Ruiz (PedroPareja@Gmail.com)
4 
5  This file is part of NetLink Sockets.
6 
7  NetLink Sockets is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  NetLink Sockets is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with NetLink Sockets. If not, see <http://www.gnu.org/licenses/>.
19 
20 */
21 
22 #ifdef DOXYGEN
23  #include <netlink/socket_group.h>
24  NL_NAMESPACE
25 #endif
26 
27 
35 inline void SocketGroup::add(Socket* socket) {
36 
37  _vSocket.push_back(socket);
38 }
39 
49 inline Socket* SocketGroup::get(unsigned index) const {
50 
51  if(index >= _vSocket.size())
52  throw Exception(Exception::OUT_OF_RANGE, "SocketGroup::get: index out of range");
53 
54  return _vSocket[index];
55 }
56 
65 inline void SocketGroup::remove(unsigned index) {
66 
67  if(index >= _vSocket.size())
68  throw Exception(Exception::OUT_OF_RANGE, "SocketGroup::remove: index out of range");
69 
70  _vSocket.erase(_vSocket.begin() + index);
71 }
72 
79 inline size_t SocketGroup::size() const {
80 
81  return _vSocket.size();
82 }
83 
92 inline void SocketGroup::setCmdOnAccept(SocketGroupCmd* cmd) {
93 
94  _cmdOnAccept = cmd;
95 }
96 
105 inline void SocketGroup::setCmdOnRead(SocketGroupCmd* cmd) {
106 
107  _cmdOnRead = cmd;
108 }
109 
119 inline void SocketGroup::setCmdOnDisconnect(SocketGroupCmd* cmd) {
120 
121  _cmdOnDisconnect = cmd;
122 }
123 
124 #ifdef DOXYGEN
125  NL_NAMESPACE_END
126 #endif
127