blob: 1f6b57064ea7d2c62f70c36768bd3f8e80fa7920 [file] [log] [blame]
Rolf Badorekef2bf512019-08-20 11:17:15 +03001/*
2 Copyright (c) 2018-2019 Nokia.
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
17#ifndef SHAREDDATALAYER_SYSTEM_HPP_
18#define SHAREDDATALAYER_SYSTEM_HPP_
19
20#include <unistd.h>
21#include <sys/poll.h>
22#include <chrono>
23
24extern "C"
25{
26 struct epoll_event;
27 struct itimerspec;
28}
29
30namespace shareddatalayer
31{
32 class System
33 {
34 public:
35 System() = default;
36
37 System(const System&) = delete;
38
39 System& operator = (const System&) = delete;
40
41 virtual ~System() = default;
42
43 virtual int poll(struct pollfd *fds, nfds_t nfds, int timeout);
44
45 virtual int epoll_create1(int flags);
46
47 virtual void epoll_ctl(int epfd, int op, int fd, epoll_event* event);
48
49 virtual int epoll_wait(int epfd, epoll_event* events, int maxevents, int timeout);
50
51 virtual int timerfd_create(int clockid, int flags);
52
53 virtual void timerfd_settime(int fd, int flags, const itimerspec* new_value, itimerspec* old_value);
54
55 virtual ssize_t read(int fd, void* buf, size_t count);
56
57 virtual int eventfd(unsigned int initval, int flags);
58
59 virtual ssize_t write(int fd, const void* buf, size_t count);
60
61 virtual std::chrono::steady_clock::duration time_since_epoch();
62
63 virtual void close(int fd);
64
65 virtual const char* getenv(const char* name);
66
67 static System& getSystem() noexcept;
68 };
69}
70
71#endif