ucommon  7.0.0
About: GNU uCommon C++ is a portable and optimized class framework for writing C++ applications that need to use threads and support concurrent synchronization, and that use sockets, XML parsing, object serialization, thread-optimized string and data structure classes, etc..
  Fossies Dox: ucommon-7.0.0.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

protocols.h
Go to the documentation of this file.
1 // Copyright (C) 2006-2014 David Sugar, Tycho Softworks.
2 // Copyright (C) 2015 Cherokees of Idaho.
3 //
4 // This file is part of GNU uCommon C++.
5 //
6 // GNU uCommon C++ is free software: you can redistribute it and/or modify
7 // it under the terms of the GNU Lesser General Public License as published
8 // by the Free Software Foundation, either version 3 of the License, or
9 // (at your option) any later version.
10 //
11 // GNU uCommon C++ is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with GNU uCommon C++. If not, see <http://www.gnu.org/licenses/>.
18 
31 #ifndef _UCOMMON_PROTOCOLS_H_
32 #define _UCOMMON_PROTOCOLS_H_
33 
34 #ifndef _UCOMMON_CPR_H_
35 #include <ucommon/cpr.h>
36 #endif
37 
38 namespace ucommon {
39 
40 class String;
41 class StringPager;
42 
44 {
45 protected:
46  friend class MemoryRedirect;
47 
55  virtual void *_alloc(size_t size) = 0;
56 
57 public:
58  virtual ~MemoryProtocol();
59 
65  inline void *alloc(size_t size) {
66  return _alloc(size);
67  }
68 
76  void *zalloc(size_t size);
77 
84  char *dup(const char *string);
85 
92  void *dup(void *memory, size_t size);
93 };
94 
101 {
102 private:
104 
105 public:
106  MemoryRedirect(MemoryProtocol *protocol);
107 
108  virtual void *_alloc(size_t size) __OVERRIDE;
109 };
110 
119 {
120 protected:
121  virtual void _lock(void);
122  virtual void _unlock(void);
123 
124 public:
125  virtual ~LockingProtocol();
126 };
127 
135 {
136 public:
137  virtual ~PrintProtocol();
138 
142  virtual const char *_print(void) const = 0;
143 };
144 
154 {
155 public:
156  virtual ~InputProtocol();
157 
163  virtual int _input(int code) = 0;
164 };
165 
174 {
175 public:
179  virtual void retain(void) = 0;
180 
184  virtual void release(void) = 0;
185 
189  virtual ~ObjectProtocol();
190 
194  ObjectProtocol *copy(void);
195 
199  inline void operator++(void) {
200  retain();
201  }
202 
206  inline void operator--(void) {
207  release();
208  }
209 };
210 
215 {
216 protected:
217  virtual int keytype(void) const = 0;
218 
222  virtual size_t keysize(void) const = 0;
223 
227  virtual const void *keydata(void) const = 0;
228 
229  virtual bool equal(const KeyProtocol& compare) const;
230 
231  inline bool operator!=(const KeyProtocol& compare) const {
232  return !equal(compare);
233  }
234 
235  virtual ~KeyProtocol();
236 };
237 
238 } // namespace ucommon
239 
240 #endif
ucommon::PrintProtocol
Definition: protocols.h:134
ucommon::InputProtocol
Definition: protocols.h:153
ucommon::ObjectProtocol::operator++
void operator++(void)
Definition: protocols.h:199
ucommon
Definition: access.cpp:23
ost::String
ucommon::String String
Definition: string.h:54
ucommon::keydata
Definition: keydata.h:58
__OVERRIDE
#define __OVERRIDE
Definition: platform.h:158
ucommon::MemoryRedirect
Definition: protocols.h:100
ucommon::ObjectProtocol
Definition: protocols.h:173
ucommon::copy
T copy(const T &src)
Definition: generics.h:395
ucommon::LockingProtocol
Definition: protocols.h:118
__EXPORT
#define __EXPORT
Definition: config.h:49
ucommon::MemoryProtocol
Definition: protocols.h:43
ucommon::KeyProtocol::operator!=
bool operator!=(const KeyProtocol &compare) const
Definition: protocols.h:231
ucommon::dup
T * dup(const T &object)
Definition: generics.h:324
cpr.h
ucommon::MemoryProtocol::alloc
void * alloc(size_t size)
Definition: protocols.h:65
ucommon::MemoryRedirect::target
MemoryProtocol * target
Definition: protocols.h:103
__PROTOCOL
#define __PROTOCOL
Definition: platform.h:112
ucommon::ObjectProtocol::operator--
void operator--(void)
Definition: protocols.h:206
ucommon::KeyProtocol
Definition: protocols.h:214