Face Engine SDK  5.14.0
A face detection, recognition and tracking engine.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
IObject.h
Go to the documentation of this file.
1 
8 #pragma once
9 
10 #include <fsdk/IRefCounted.h>
11 #include <fsdk/Types.h>
12 
13 namespace fsdk {
14 
21  struct ISettingsProvider;
22 
37  struct IArchive {
38 
45  virtual bool write(const void* data, size_t size) = 0;
46 
53  virtual bool read(void* data, size_t size) = 0;
54 
59  virtual void setSizeHint(size_t hint) { ((void)hint); }
60 
61  virtual ~IArchive() = default;
62  };
63 
69 
73  enum class Error : uint32_t {
74  Ok,
75  Size,
76  Signature,
77  ArchiveRead,
78  InputArchive,
79  ArchiveWrite,
80  };
81 
88  enum Flags {
89 
91  Default = 0,
92 
101  };
102 
108  virtual void getSize(Sizer& sizer, uint32_t flags = Default) const noexcept = 0;
109 
118  virtual Result<Error> load(IArchive* archive, uint32_t flags = Default) = 0;
119 
128  virtual Result<Error> save(IArchive* archive, uint32_t flags = Default) const = 0;
129  };
130 
134  template<>
136 
137  static bool isOk(ISerializableObject::Error error) noexcept {
138  return error == ISerializableObject::Error::Ok;
139  }
140 
141  static const char* toString (ISerializableObject::Error error) noexcept {
142  switch(error) {
143  case ISerializableObject::Error::Ok : return "Ok";
144  case ISerializableObject::Error::Size: return "Size error";
145  case ISerializableObject::Error::Signature: return "Signature error";
146  case ISerializableObject::Error::ArchiveRead: return "Error during archive reading";
147  case ISerializableObject::Error::InputArchive: return "Input archive is nullptr";
148  case ISerializableObject::Error::ArchiveWrite: return "Error during archive writing";
149  default: return "Unknown error";
150  }
151  }
152  };
153 
158 
164  virtual void clear() noexcept = 0;
165 
173  virtual IRefCounted* getParentObject() const noexcept = 0;
174  };
175 
177 }
Error during archive writing,.
virtual bool write(const void *data, size_t size)=0
Write bytes to archive.
virtual Result< Error > save(IArchive *archive, uint32_t flags=Default) const =0
Save object to archive.
A structure that encapsulates an action result enumeration.
Definition: Result.h:29
Common data types and structures.
virtual Result< Error > load(IArchive *archive, uint32_t flags=Default)=0
Load object from archive.
Error during archive reading,.
Serializable object interface.
Definition: IObject.h:68
Definition: Result.h:9
Base strong reference counted object interface.
Definition: IRefCounted.h:36
virtual void getSize(Sizer &sizer, uint32_t flags=Default) const noexcept=0
Estimate size of this object binary data.
Default serialization mode.
Definition: IObject.h:91
virtual void setSizeHint(size_t hint)
Set size hint.
Definition: IObject.h:59
Error
Serialization nerror codes.
Definition: IObject.h:73
Flags
Serialization flags.
Definition: IObject.h:88
Omit object signature.
Definition: IObject.h:100
Data storage object interface helper.
Definition: IObject.h:157
Archive interface.
Definition: IObject.h:37
virtual bool read(void *data, size_t size)=0
Read bytes from archive.
Helper entity to measure size of dynamic objects in memory.
Definition: Sizer.h:10
Reference counted object interface.