From 76821551f312dd447a03748a01670f3718cd8345 Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 26 Sep 2024 14:43:22 -0700 Subject: Basic update to new API for existing components. This may not all work yet, but it all compiles! --- src/stable/myriad.h | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) (limited to 'src/stable/myriad.h') diff --git a/src/stable/myriad.h b/src/stable/myriad.h index 58f700a..c3f682d 100644 --- a/src/stable/myriad.h +++ b/src/stable/myriad.h @@ -32,7 +32,7 @@ namespace Bu { public: typedef int32_t StreamId; - enum Mode { + enum Mode : int32_t { None = 0x00, // Flags @@ -75,6 +75,8 @@ namespace Bu MyriadStream open( StreamId iStream, Mode eMode ); void erase( StreamId iStream ); void setSize( StreamId iStream, int32_t iNewSize ); + int32_t getSize( StreamId iStream ) const; + bool exists( StreamId iStream ) const; Bu::String getLocation() const; int32_t getBlockSize() const; int32_t getTotalBlocks() const; @@ -84,6 +86,12 @@ namespace Bu int32_t getTotalUsedBytes() const; int32_t getTotalUnusedBytes( int32_t iAssumeBlockSize=-1 ) const; + /** + * Flush all caches to the backing stream, write all structural and + * header changes. + */ + void sync(); + private: bool loadMyriad(); void createMyriad( int32_t iBlockSize, int32_t iPreallocateBlocks ); @@ -175,6 +183,20 @@ namespace Bu IndexList lFreeBlocks; StreamId iLastUsedIndex; }; + constexpr Myriad::Mode operator&( Myriad::Mode a, Myriad::Mode b ) + { + return static_cast( + static_cast::type>(a) & + static_cast::type>(b) + ); + } + constexpr Myriad::Mode operator|( Myriad::Mode a, Myriad::Mode b ) + { + return static_cast( + static_cast::type>(a) | + static_cast::type>(b) + ); + } }; #endif -- cgit v1.2.3