Acacia
atspi_interface.h
1 #ifndef INCLUDE_ACACIA_ATSPI_ATSPI_INTERFACE_H_
2 #define INCLUDE_ACACIA_ATSPI_ATSPI_INTERFACE_H_
3 
4 #include <iostream>
5 #include <memory>
6 #include <string>
7 
8 #include <atspi/atspi.h>
9 
10 namespace acacia {
11 
17 template <typename T>
19  public:
20  explicit AtspiInterface(T* interface) : interface_(interface, Deleter()) {}
21 
22  AtspiInterface() {}
23  virtual ~AtspiInterface() {}
24 
28  bool isNull() const { return !interface_; }
29 
34  virtual std::string toString() const = 0;
35 
36  protected:
37  class Deleter {
38  public:
39  void operator()(T* ptr) {
40  if (ptr == nullptr)
41  return;
42  g_object_unref(ptr);
43  }
44  };
45 
46  std::shared_ptr<T> interface_{nullptr};
47 };
48 
49 } // namespace acacia
50 
51 #endif // INCLUDE_ACACIA_ATSPI_ATSPI_INTERFACE_H_
Definition: atspi_interface.h:37
Definition: atspi_interface.h:18
virtual std::string toString() const =0
bool isNull() const
Definition: atspi_interface.h:28