| Face Engine SDK 5.2.0 A face detection, recognition and tracking engine.

IObject.h
Go to the documentation of this file.
1
8 #pragma once
9
10 #include "IRefCounted.h"
11 #include "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
68 struct ISerializableObject : IRefCounted {
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
100 NoSignature = 1
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<>
135 struct ErrorTraits<ISerializableObject::Error> {
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
157 struct IDataStorageObject : ISerializableObject {
158
164 virtual void clear() noexcept = 0;
165
173 virtual IRefCounted* getParentObject() const noexcept = 0;
174 };
175
177 }
fsdk::IDataStorageObject
Data storage object interface helper.
Definition: IObject.h:157
IRefCounted.h
Reference counted object interface.
fsdk::ISerializableObject::load
virtual Result< Error > load(IArchive *archive, uint32_t flags=Default)=0
Load object from archive.
fsdk::IArchive::read
virtual bool read(void *data, size_t size)=0
Read bytes from archive.
fsdk::ISerializableObject::Error::Ok
@ Ok
Ok.
fsdk::IDataStorageObject::getParentObject
virtual IRefCounted * getParentObject() const noexcept=0
Get parent object (one that has created this).
fsdk::ISerializableObject::Error::ArchiveWrite
@ ArchiveWrite
Error during archive writing,.
fsdk
SDK namespace.
Definition: IAGSEstimator.h:8
fsdk::ISerializableObject::Error::Size
@ Size
Not enough space.
fsdk::ISerializableObject::Error::Signature
@ Signature
Invalid signature.
fsdk::ISerializableObject::Error
Error
Serialization nerror codes.
Definition: IObject.h:73
fsdk::IArchive::write
virtual bool write(const void *data, size_t size)=0
Write bytes to archive.
fsdk::ISerializableObject::save
virtual Result< Error > save(IArchive *archive, uint32_t flags=Default) const =0
Save object to archive.
fsdk::ISerializableObject
Serializable object interface.
Definition: IObject.h:68
fsdk::ISerializableObject::Error::ArchiveRead
@ ArchiveRead
Error during archive reading,.
fsdk::ISerializableObject::Default
@ Default
Default serialization mode.
Definition: IObject.h:91
fsdk::IDataStorageObject::clear
virtual void clear() noexcept=0
Clear object data.
fsdk::ISerializableObject::getSize
virtual void getSize(Sizer &sizer, uint32_t flags=Default) const noexcept=0
Estimate size of this object binary data.
fsdk::IArchive
Archive interface.
Definition: IObject.h:37
fsdk::ErrorTraits
Definition: Result.h:10
Types.h
Common data types and structures.
fsdk::ISerializableObject::Flags
Flags
Serialization flags.
Definition: IObject.h:88
fsdk::Result
A structure that encapsulates an action result enumeration.
Definition: Result.h:30
fsdk::ISerializableObject::Error::InputArchive
@ InputArchive
Input archive is nullptr.
fsdk::ISerializableObject::NoSignature
@ NoSignature
Omit object signature.
Definition: IObject.h:100
fsdk::IArchive::setSizeHint
virtual void setSizeHint(size_t hint)
Set size hint.
Definition: IObject.h:59
fsdk::IRefCounted
Base strong reference counted object interface.
Definition: IRefCounted.h:36
fsdk::Sizer
Helper entity to measure size of dynamic objects in memory.
Definition: Sizer.h:10