Face Engine SDK  5.25.0
A face detection, recognition and tracking engine.
include/fsdk/IObject.h
Go to the documentation of this file.
00001 
00008 #pragma once
00009 
00010 #include <fsdk/IRefCounted.h>
00011 #include <fsdk/Types.h>
00012 
00013 namespace fsdk {
00014 
00021     struct ISettingsProvider;
00022 
00038     struct IArchive {
00039 
00046         virtual bool write(const void* data, size_t size) = 0;
00047 
00054         virtual bool read(void* data, size_t size) = 0;
00055 
00060         virtual void setSizeHint(size_t hint) {
00061             ((void)hint);
00062         }
00063 
00064         virtual ~IArchive() = default;
00065     };
00066 
00071     struct ISerializableObject : IRefCounted {
00072 
00076         enum class Error : uint32_t {
00077             Ok,           
00078             Size,         
00079             Signature,    
00080             ArchiveRead,  
00081             InputArchive, 
00082             ArchiveWrite, 
00083         };
00084 
00091         enum Flags {
00092 
00094             Default = 0,
00095 
00103             NoSignature = 1
00104         };
00105 
00111         virtual void getSize(Sizer& sizer, uint32_t flags = Default) const noexcept = 0;
00112 
00121         virtual Result<Error> load(IArchive* archive, uint32_t flags = Default) = 0;
00122 
00131         virtual Result<Error> save(IArchive* archive, uint32_t flags = Default) const = 0;
00132     };
00133 
00137     template <>
00138     struct ErrorTraits<ISerializableObject::Error> {
00139 
00140         static bool isOk(ISerializableObject::Error error) noexcept {
00141             return error == ISerializableObject::Error::Ok;
00142         }
00143 
00144         static const char* toString(ISerializableObject::Error error) noexcept {
00145             switch(error) {
00146             case ISerializableObject::Error::Ok:
00147                 return "Ok";
00148             case ISerializableObject::Error::Size:
00149                 return "Size error";
00150             case ISerializableObject::Error::Signature:
00151                 return "Signature error";
00152             case ISerializableObject::Error::ArchiveRead:
00153                 return "Error during archive reading";
00154             case ISerializableObject::Error::InputArchive:
00155                 return "Input archive is nullptr";
00156             case ISerializableObject::Error::ArchiveWrite:
00157                 return "Error during archive writing";
00158             default:
00159                 return "Unknown error";
00160             }
00161         }
00162     };
00163 
00167     struct IDataStorageObject : ISerializableObject {
00168 
00174         virtual void clear() noexcept = 0;
00175 
00183         virtual IRefCounted* getParentObject() const noexcept = 0;
00184     };
00185 
00187 } // namespace fsdk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines