4S Device Communication Module Collection  Version 0.6-SNAPSHOT
Full documentation of the modules in the 4SDC collection (aimed at 4SDC module developers)
handle.h
Go to the documentation of this file.
1 /*
2  * Copyright 2014-2015 The 4S Foundation (www.4s-online.dk)
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 
31 #ifndef HANDLE_H
32 #define HANDLE_H
33 
34 #include <cstdint>
35 
36 namespace FSYS
37 {
55  class Handle
56  {
60  int64_t handle;
61 
73  int64_t getNextHandle( void );
74  public:
75 
110  Handle( void ) {handle = getNextHandle();}
111 
116  Handle( Handle &ref ) : handle(ref.handle) {}
117 
122  Handle( const Handle &ref ) : handle(ref.handle) {}
123 
124  inline Handle& operator= (Handle const &theOtherOne) {handle = theOtherOne.handle; return *this;}
125 
135  inline bool operator==(Handle const &compareTo) const
136  {
137  return (this->handle == compareTo.handle);
138  }
139 
150  inline bool operator!=(Handle const &compareTo) const
151  {
152  return (this->handle != compareTo.handle);
153  }
154 
174  inline bool operator>(Handle const &compareTo) const
175  {
176  return (this->handle > compareTo.handle);
177  }
178 
193  inline bool operator<(Handle const &compareTo) const
194  {
195  return (this->handle < compareTo.handle);
196  }
197 
206  static Handle &broadCastHandle( void );
207 
226  static Handle &null( void );
227  };
228 }
229 
230 #endif // HANDLE_H
static Handle & null(void)
The null handle.
Definition: handle.cpp:57
Handle(const Handle &ref)
Copy constructor for handle object.
Definition: handle.h:122
Handle(void)
Default constructor.
Definition: handle.h:110
bool operator==(Handle const &compareTo) const
Equality comparator.
Definition: handle.h:135
bool operator<(Handle const &compareTo) const
Less than operator (&#39;<&#39;)
Definition: handle.h:193
Class that holds and assigns handles.
Definition: handle.h:55
bool operator>(Handle const &compareTo) const
Greater than operator (&#39;>&#39;)
Definition: handle.h:174
static Handle & broadCastHandle(void)
Generic broadcast handle.
Definition: handle.cpp:49
int64_t handle
The actual value of the handle.
Definition: handle.h:60
int64_t getNextHandle(void)
Function to generate a unique handle.
Definition: handle.cpp:38
Definition: basemsg.h:38
Handle(Handle &ref)
Copy constructor for handle object.
Definition: handle.h:116
bool operator!=(Handle const &compareTo) const
Not equalify operator.
Definition: handle.h:150