GpgFrontend Project
A Free, Powerful, Easy-to-Use, Compact, Cross-Platform, and Installation-Free OpenPGP(pgp) Crypto Tool.
ChannelObject.h
1 
29 #pragma once
30 
31 #include "core/GpgConstants.h"
32 #include "core/function/SecureMemoryAllocator.h"
33 namespace GpgFrontend {
34 
39 class GPGFRONTEND_CORE_EXPORT ChannelObject {
40  public:
45  ChannelObject() noexcept;
46 
51  virtual ~ChannelObject() noexcept;
52 
58  explicit ChannelObject(int channel, QString type);
59 
65  static auto GetDefaultChannel() -> int;
66 
72  [[nodiscard]] auto GetChannel() const -> int;
73 
79  void SetChannel(int channel);
80 
81  private:
82  int channel_ = kGpgFrontendDefaultChannel;
83  QString type_;
84 };
85 
86 template <typename Derived>
87 auto ConvertToChannelObjectPtr(
88  std::unique_ptr<Derived, SecureObjectDeleter<Derived>> derivedPtr)
89  -> std::unique_ptr<ChannelObject, SecureObjectDeleter<ChannelObject>> {
90  static_assert(std::is_base_of_v<ChannelObject, Derived>,
91  "Derived must be a subclass of ChannelObject");
92 
93  ChannelObject* base_ptr = derivedPtr.release();
94  return std::unique_ptr<ChannelObject, SecureObjectDeleter<ChannelObject>>(
95  base_ptr);
96 }
97 
98 } // namespace GpgFrontend
object which in channel system is called "channel"
Definition: ChannelObject.h:39
ChannelObject() noexcept
Construct a new Default Channel Object object.
Definition: app.cpp:39
Definition: SecureMemoryAllocator.h:46