blob: b26fb846294a0d6b3d6f13861ae8e87f35f030b4 [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
Timo Tietavainena0745d22019-11-28 09:55:22 +020017/*
18 * This source code is part of the near-RT RIC (RAN Intelligent Controller)
19 * platform project (RICP).
20*/
21
Rolf Badorekef2bf512019-08-20 11:17:15 +030022#ifndef SHAREDDATALAYER_SYSTEM_HPP_
23#define SHAREDDATALAYER_SYSTEM_HPP_
24
25#include <unistd.h>
26#include <sys/poll.h>
27#include <chrono>
28
29extern "C"
30{
31 struct epoll_event;
32 struct itimerspec;
33}
34
35namespace shareddatalayer
36{
37 class System
38 {
39 public:
40 System() = default;
41
42 System(const System&) = delete;
43
44 System& operator = (const System&) = delete;
45
46 virtual ~System() = default;
47
48 virtual int poll(struct pollfd *fds, nfds_t nfds, int timeout);
49
50 virtual int epoll_create1(int flags);
51
52 virtual void epoll_ctl(int epfd, int op, int fd, epoll_event* event);
53
54 virtual int epoll_wait(int epfd, epoll_event* events, int maxevents, int timeout);
55
56 virtual int timerfd_create(int clockid, int flags);
57
58 virtual void timerfd_settime(int fd, int flags, const itimerspec* new_value, itimerspec* old_value);
59
60 virtual ssize_t read(int fd, void* buf, size_t count);
61
62 virtual int eventfd(unsigned int initval, int flags);
63
64 virtual ssize_t write(int fd, const void* buf, size_t count);
65
66 virtual std::chrono::steady_clock::duration time_since_epoch();
67
68 virtual void close(int fd);
69
70 virtual const char* getenv(const char* name);
71
72 static System& getSystem() noexcept;
73 };
74}
75
76#endif