WPILibC++  2018.4.1-20180819050225-1157-gb44f27d
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
FsEvent.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2018 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #ifndef WPIUTIL_WPI_UV_FSEVENT_H_
9 #define WPIUTIL_WPI_UV_FSEVENT_H_
10 
11 #include <uv.h>
12 
13 #include <memory>
14 #include <string>
15 
16 #include "wpi/Signal.h"
17 #include "wpi/Twine.h"
18 #include "wpi/uv/Handle.h"
19 
20 namespace wpi {
21 namespace uv {
22 
23 class Loop;
24 
28 class FsEvent final : public HandleImpl<FsEvent, uv_fs_event_t> {
29  struct private_init {};
30 
31  public:
32  explicit FsEvent(const private_init&) {}
33  ~FsEvent() noexcept override = default;
34 
40  static std::shared_ptr<FsEvent> Create(Loop& loop);
41 
47  static std::shared_ptr<FsEvent> Create(const std::shared_ptr<Loop>& loop) {
48  return Create(*loop);
49  }
50 
58  void Start(const Twine& path, unsigned int flags = 0);
59 
63  void Stop() { Invoke(&uv_fs_event_stop, GetRaw()); }
64 
70  std::string GetPath();
71 
79 };
80 
81 } // namespace uv
82 } // namespace wpi
83 
84 #endif // WPIUTIL_WPI_UV_FSEVENT_H_
uv_fs_event_t * GetRaw() const noexcept
Get the underlying handle data structure.
Definition: Handle.h:261
Handle.
Definition: Handle.h:246
std::string GetPath()
Get the path being monitored.
WPILib C++ utilities (wpiutil) namespace.
Definition: SmallString.h:21
Filesystem Event handle.
Definition: FsEvent.h:28
sig::Signal< const char *, int > fsEvent
Signal generated when a filesystem change occurs.
Definition: FsEvent.h:78
void Stop()
Stop watching for changes.
Definition: FsEvent.h:63
void Start(const Twine &path, unsigned int flags=0)
Start watching the specified path for changes.
static std::shared_ptr< FsEvent > Create(Loop &loop)
Create a filesystem event handle.
Event loop.
Definition: Loop.h:37
static std::shared_ptr< FsEvent > Create(const std::shared_ptr< Loop > &loop)
Create a filesystem event handle.
Definition: FsEvent.h:47
SignalBase is an implementation of the observer pattern, through the use of an emitting object and sl...
Definition: Signal.h:495
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:79