FINAL CUT
fsystem.h
1 /***********************************************************************
2 * fsystem.h - Abstract class for system calls *
3 * *
4 * This file is part of the FINAL CUT widget toolkit *
5 * *
6 * Copyright 2019-2023 Markus Gans *
7 * *
8 * FINAL CUT is free software; you can redistribute it and/or modify *
9 * it under the terms of the GNU Lesser General Public License as *
10 * published by the Free Software Foundation; either version 3 of *
11 * the License, or (at your option) any later version. *
12 * *
13 * FINAL CUT is distributed in the hope that it will be useful, but *
14 * WITHOUT ANY WARRANTY; without even the implied warranty of *
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16 * GNU Lesser General Public License for more details. *
17 * *
18 * You should have received a copy of the GNU Lesser General Public *
19 * License along with this program. If not, see *
20 * <http://www.gnu.org/licenses/>. *
21 ***********************************************************************/
22 
23 /* Standalone class
24  * ════════════════
25  *
26  * ▕▔▔▔▔▔▔▔▔▔▏
27  * ▕ FSystem ▏
28  * ▕▁▁▁▁▁▁▁▁▁▏
29  */
30 
31 #ifndef FSYSTEM_H
32 #define FSYSTEM_H
33 
34 #if !defined (USE_FINAL_H) && !defined (COMPILE_FINAL_CUT)
35  #error "Only <final/final.h> can be included directly."
36 #endif
37 
38 #ifdef __APPLE__
39  using timer_t = void*;
40 #endif
41 
42 #include <memory>
43 #include <pwd.h>
44 
45 #include "final/ftypes.h"
46 
47 // struct forward declaration
48 struct kevent;
49 
50 namespace finalcut
51 {
52 
53 //----------------------------------------------------------------------
54 // class FSystem
55 //----------------------------------------------------------------------
56 
57 class FSystem
58 {
59  public:
60  // Constructor
61  FSystem() = default;
62 
63  // Destructor
64  virtual ~FSystem() noexcept;
65 
66  // Accessor
67  static auto getInstance() -> std::unique_ptr<FSystem>&;
68 
69  // Methods
70  virtual auto inPortByte (uShort) -> uChar = 0;
71  virtual void outPortByte (uChar, uShort) = 0;
72  virtual auto isTTY (int) const -> int = 0;
73  virtual auto ioctl (int, uLong, ...) -> int = 0;
74  virtual auto pipe (PipeData&) -> int = 0;
75  virtual auto open (const char*, int, ...) -> int = 0;
76  virtual auto close (int) -> int = 0;
77  virtual auto fopen (const char*, const char*) -> FILE* = 0;
78  virtual auto fclose (FILE*) -> int = 0;
79  virtual auto fputs (const char*, FILE*) -> int = 0;
80  virtual auto putchar (int) -> int = 0;
81  virtual auto sigaction ( int, const struct sigaction*
82  , struct sigaction* ) -> int = 0;
83  virtual auto timer_create ( clockid_t, struct sigevent*
84  , timer_t* ) -> int = 0;
85  virtual auto timer_settime ( timer_t, int,
86  const struct itimerspec*,
87  struct itimerspec* ) -> int = 0;
88  virtual auto timer_delete (timer_t) -> int = 0;
89  virtual auto kqueue() -> int = 0;
90  virtual auto kevent ( int, const struct kevent*
91  , int, struct kevent*
92  , int, const struct timespec* ) -> int = 0;
93  virtual auto getuid() -> uid_t = 0;
94  virtual auto geteuid() -> uid_t = 0;
95  virtual auto getpwuid_r ( uid_t, struct passwd*, char*
96  , size_t, struct passwd**) -> int = 0;
97  virtual auto realpath (const char*, char*) -> char* = 0;
98 };
99 
100 } // namespace finalcut
101 
102 #endif // FSYSTEM_H
Definition: fsystem.h:57
Definition: class_template.cpp:25
Definition: pipedata.h:47