1 /*
2 ** Copyright 2011-2013,2019 Centreon
3 **
4 ** Licensed under the Apache License, Version 2.0 (the "License");
5 ** you may not use this file except in compliance with the License.
6 ** You may obtain a copy of the License at
7 **
8 **     http://www.apache.org/licenses/LICENSE-2.0
9 **
10 ** Unless required by applicable law or agreed to in writing, software
11 ** distributed under the License is distributed on an "AS IS" BASIS,
12 ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 ** See the License for the specific language governing permissions and
14 ** limitations under the License.
15 **
16 ** For more information : contact@centreon.com
17 */
18 
19 #ifndef CC_HANDLE_HH
20 #define CC_HANDLE_HH
21 
22 #include "com/centreon/namespace.hh"
23 
24 CC_BEGIN()
25 
26 typedef int native_handle;
27 native_handle const native_handle_null = -1;
28 
29 /**
30  *  @class handle handle.hh "com/centreon/handle.hh"
31  *  @brief Base for all handle objetcs.
32  *
33  *  This class is an interface for system handle.
34  */
35 class handle {
36  public:
37   handle() = default;
38   virtual ~handle() = default;
39   handle(handle const& right) = delete;
40   handle& operator=(handle const& right) = delete;
41 
42   virtual void close() = 0;
43   virtual native_handle get_native_handle() = 0;
44   virtual unsigned long read(void* data, unsigned long size) = 0;
45   virtual unsigned long write(void const* data, unsigned long size) = 0;
46 };
47 
48 CC_END()
49 
50 #endif  // !CC_HANDLE_HH
51