Flutter Impeller
impeller::Archive Class Reference

#include <archive.h>

Public Types

using UnarchiveStep = std::function< bool(ArchiveLocation &)>
 

Public Member Functions

 Archive (const std::string &path)
 
 ~Archive ()
 
bool IsValid () const
 
template<class T , class = std::enable_if_t<std::is_base_of<Archivable, T>::value>>
bool Write (const T &archivable)
 
template<class T , class = std::enable_if_t<std::is_base_of<Archivable, T>::value>>
bool Read (PrimaryKey name, T &archivable)
 
template<class T , class = std::enable_if_t<std::is_base_of<Archivable, T>::value>>
size_t Read (const UnarchiveStep &stepper)
 

Friends

class ArchiveLocation
 

Detailed Description

Definition at line 21 of file archive.h.

Member Typedef Documentation

◆ UnarchiveStep

using impeller::Archive::UnarchiveStep = std::function<bool(ArchiveLocation&)>

Definition at line 43 of file archive.h.

Constructor & Destructor Documentation

◆ Archive()

impeller::Archive::Archive ( const std::string &  path)
explicit

Definition at line 14 of file archive.cc.

15  : database_(std::make_unique<ArchiveDatabase>(path)) {}

◆ ~Archive()

impeller::Archive::~Archive ( )

Definition at line 17 of file archive.cc.

17  {
18  FML_DCHECK(transaction_count_ == 0)
19  << "There must be no pending transactions";
20 }

Member Function Documentation

◆ IsValid()

bool impeller::Archive::IsValid ( ) const

Definition at line 22 of file archive.cc.

22  {
23  return database_->IsValid();
24 }

Referenced by impeller::testing::TEST_F().

◆ Read() [1/2]

template<class T , class = std::enable_if_t<std::is_base_of<Archivable, T>::value>>
size_t impeller::Archive::Read ( const UnarchiveStep stepper)
inline

Definition at line 47 of file archive.h.

47  {
48  const ArchiveDef& def = T::kArchiveDefinition;
49  return UnarchiveInstances(def, stepper);
50  }

◆ Read() [2/2]

template<class T , class = std::enable_if_t<std::is_base_of<Archivable, T>::value>>
bool impeller::Archive::Read ( PrimaryKey  name,
T &  archivable 
)
inline

Definition at line 38 of file archive.h.

38  {
39  const ArchiveDef& def = T::kArchiveDefinition;
40  return UnarchiveInstance(def, name, archivable);
41  }

Referenced by impeller::testing::TEST_F().

◆ Write()

template<class T , class = std::enable_if_t<std::is_base_of<Archivable, T>::value>>
bool impeller::Archive::Write ( const T &  archivable)
inline

Definition at line 31 of file archive.h.

31  {
32  const ArchiveDef& def = T::kArchiveDefinition;
33  return ArchiveInstance(def, archivable).has_value();
34  }

Referenced by impeller::testing::TEST_F().

Friends And Related Function Documentation

◆ ArchiveLocation

friend class ArchiveLocation
friend

Definition at line 56 of file archive.h.


The documentation for this class was generated from the following files: