30#include <osl/diagnose.h>
31#include <osl/endian.h>
60inline sal_uInt16
htons (sal_uInt16 h) {
return OSL_SWAPWORD(h); }
61inline sal_uInt16
ntohs (sal_uInt16 n) {
return OSL_SWAPWORD(n); }
63inline sal_uInt32
htonl (sal_uInt32 h) {
return OSL_SWAPDWORD(h); }
64inline sal_uInt32
ntohl (sal_uInt32 n) {
return OSL_SWAPDWORD(n); }
66inline sal_uInt16
htons (sal_uInt16 h) {
return h; }
67inline sal_uInt16
ntohs (sal_uInt16 n) {
return n; }
69inline sal_uInt32
htonl (sal_uInt32 h) {
return h; }
70inline sal_uInt32
ntohl (sal_uInt32 n) {
return n; }
114#define STORE_PAGE_NULL (sal_uInt32(~0))
250 static const size_t theSize =
sizeof(
G) +
sizeof(
D) + 2 *
sizeof(
L);
281 class Allocator_Impl;
287 void * page =
nullptr;
288 sal_uInt16 nSize = 0;
291 return new(page) T(nSize);
296 bool allocate (
void ** ppPage, sal_uInt16 * pnSize)
299 return ((*ppPage !=
nullptr) && (*pnSize != 0));
304 if (pPage !=
nullptr)
332 static void*
operator new (size_t,
void *
p) {
return p; }
333 static void operator delete (
void * ,
void *) {}
372 nCRC32 = rtl_crc32 (nCRC32, &
m_aDescr,
static_cast<sal_uInt32
>(
theSize -
sizeof(
G)));
381 nCRC32 = rtl_crc32 (nCRC32, &
m_aDescr,
static_cast<sal_uInt32
>(
theSize -
sizeof(
G)));
403 return ((
p !=
nullptr) && (
p->type() == U::theTypeId));
409 return isA<U>(
p) ?
static_cast<U*
>(
p) :
nullptr;
415 return isA<U>(
p) ?
static_cast<U const *
>(
p) :
nullptr;
421 if (!
m_xPage && rxAllocator.is())
455 std::shared_ptr<PageData>
const &
get()
const {
return m_xPage; }
459 T * pImpl = dynamic_page_cast<T>(
m_xPage.get());
460 OSL_PRECOND(pImpl !=
nullptr,
"store::PageHolder<T>::operator*(): Null pointer");
466 T
const * pImpl = dynamic_page_cast<T>(
m_xPage.get());
467 OSL_PRECOND(pImpl !=
nullptr,
"store::PageHolder<T>::operator*(): Null pointer");
473 T * pImpl = dynamic_page_cast<T>(
m_xPage.get());
474 OSL_PRECOND(pImpl !=
nullptr,
"store::PageHolder<T>::operator*(): Null pointer");
480 T
const * pImpl = dynamic_page_cast<T>(
m_xPage.get());
481 OSL_PRECOND(pImpl !=
nullptr,
"store::PageHolder<T>::operator*(): Null pointer");
492 T * pImpl = dynamic_page_cast<T>(pHead);
493 OSL_PRECOND(pImpl !=
nullptr,
"store::PageHolder<T>::guard(): Null pointer");
501 PageData const * pHead = rxPage.get();
509 T
const * pImpl = dynamic_page_cast<T>(pHead);
513 return pImpl->verify();
524 static void *
operator new (
size_t n)
526 return std::malloc(sal_uInt32(
n));
528 static void operator delete (
void *
p)
535 inline bool dirty()
const;
569 if (!rxAllocator.is())
storeError construct(rtl::Reference< PageData::Allocator > const &rxAllocator)
virtual ~OStorePageObject()
Destruction.
virtual storeError guard(sal_uInt32 nAddr)=0
sal_uInt32 location() const
Location.
virtual storeError verify(sal_uInt32 nAddr) const =0
PageHolderObject< U > makeHolder() const
std::shared_ptr< PageData > & get()
std::shared_ptr< PageData > m_xPage
Representation.
OStorePageObject(std::shared_ptr< PageData > rxPage)
Construction.
virtual void deallocate_Impl(void *pPage)=0
static storeError createInstance(rtl::Reference< PageData::Allocator > &rxAllocator, sal_uInt16 nPageSize)
void deallocate(void *pPage)
bool allocate(void **ppPage, sal_uInt16 *pnSize)
virtual ~Allocator() override
virtual void allocate_Impl(void **ppPage, sal_uInt16 *pnSize)=0
Implementation (abstract).
Deallocate(rtl::Reference< Allocator > allocator)
rtl::Reference< Allocator > allocator_
void operator()(void *page) const
std::shared_ptr< PageData > const & get() const
bool construct(rtl::Reference< PageData::Allocator > const &rxAllocator)
T const & operator*() const
static bool isA(PageData const *p)
Checked cast.
void swap(PageHolderObject< T > &rhs)
static U const * dynamic_page_cast(PageData const *p)
static storeError verify(std::shared_ptr< PageData > const &rxPage, sal_uInt32 nAddr)
static storeError guard(std::shared_ptr< PageData > const &rxPage, sal_uInt32 nAddr)
PageHolderObject(std::shared_ptr< PageData > xPage=std::shared_ptr< PageData >())
std::shared_ptr< PageData > m_xPage
Representation.
std::shared_ptr< PageData > & get()
PageHolderObject< T > & operator=(PageHolderObject< T > const &rhs)
static U * dynamic_page_cast(PageData *p)
T const * operator->() const
PageHolderObject(PageHolderObject< T > const &rhs)
Old OStorePageCache implementation.
sal_uInt32 htonl(sal_uInt32 h)
sal_uInt16 ntohs(sal_uInt16 n)
sal_uInt32 ntohl(sal_uInt32 n)
sal_uInt16 htons(sal_uInt16 h)
void swap(OStorePageDescriptor &rhs)
OStorePageDescriptor & operator=(const OStorePageDescriptor &rhs)
bool operator==(const OStorePageDescriptor &rhs) const
Comparison.
OStorePageDescriptor(sal_uInt32 nAddr, sal_uInt16 nSize, sal_uInt16 nUsed)
Construction.
sal_uInt32 m_nAddr
Representation.
OStorePageDescriptor(const OStorePageDescriptor &rhs)
bool operator==(const OStorePageGuard &rhs) const
Comparison.
OStorePageGuard(sal_uInt32 nMagic=0)
Construction.
void swap(OStorePageGuard &rhs)
sal_uInt32 m_nMagic
Representation.
OStorePageGuard & operator=(const OStorePageGuard &rhs)
OStorePageGuard(OStorePageGuard const &rhs)
sal_uInt32 m_nLow
Representation.
bool operator==(const OStorePageKey &rhs) const
Comparison.
OStorePageKey(sal_uInt32 nLow=0, sal_uInt32 nHigh=0)
Construction.
bool operator<(const OStorePageKey &rhs) const
sal_uInt32 m_nAddr
Representation.
OStorePageLink & operator=(sal_uInt32 nAddr)
sal_uInt32 location() const
Operation.
OStorePageLink(sal_uInt32 nAddr=STORE_PAGE_NULL)
Construction.
void swap(OStorePageLink &rhs)
bool operator==(const OStorePageLink &rhs) const
Comparison.
G m_aGuard
Representation.
PageData(PageData const &rhs)
void guard(sal_uInt32 nAddr)
guard (external representation).
sal_uInt16 size() const
size.
sal_uInt32 type() const
type.
PageData(sal_uInt16 nPageSize=thePageSize)
Construction.
storeError verify(sal_uInt32 nAddr) const
verify (external representation).
PageData & operator=(PageData const &rhs)
static const sal_uInt16 thePageSize
sal_uInt32 location() const
location.
static const size_t theSize
theSize.
void location(sal_uInt32 nAddr)
constexpr sal_uInt16 STORE_MINIMUM_PAGESIZE
PageSize (enforced) limits.
storeError
Error Code enumeration.
@ store_E_InvalidChecksum