QCAD
Open Source 2D CAD
Loading...
Searching...
No Matches
CustomStorage.h
Go to the documentation of this file.
1/******************************************************************************
2 * Project: libsidx - A C API wrapper around libspatialindex
3 * Purpose: C++ object declarations to implement the custom storage manager.
4 * Author: Matthias (nitro), [email protected]
5 ******************************************************************************
6 * Copyright (c) 2010, Matthias (nitro)
7 *
8 * All rights reserved.
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice shall be included
18 * in all copies or substantial portions of the Software.
19 *
20 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 * DEALINGS IN THE SOFTWARE.
27******************************************************************************/
28
29#pragma once
30
31#include "sidx_export.h"
32
33namespace SpatialIndex
34{
35 namespace StorageManager
36 {
38 {
40 : context(0)
41 , createCallback(0)
42 , destroyCallback(0)
43 , loadByteArrayCallback(0)
44 , storeByteArrayCallback(0)
45 , deleteByteArrayCallback(0)
46 {}
47
48 void* context;
49 void (*createCallback)( const void* context, int* errorCode );
50 void (*destroyCallback)( const void* context, int* errorCode );
51 void (*flushCallback)( const void* context, int* errorCode );
52 void (*loadByteArrayCallback)( const void* context, const id_type page, uint32_t* len, byte** data, int* errorCode );
53 void (*storeByteArrayCallback)( const void* context, id_type* page, const uint32_t len, const byte* const data, int* errorCode );
54 void (*deleteByteArrayCallback)( const void* context, const id_type page, int* errorCode );
55 };
56
58 {
59 public:
60 // I'd like this to be an enum, but casting between enums and ints is not nice
61 static const int NoError = 0;
62 static const int InvalidPageError = 1;
63 static const int IllegalStateError = 2;
64
66
68
69 virtual void flush();
70 virtual void loadByteArray(const id_type page, uint32_t& len, byte** data);
71 virtual void storeByteArray(id_type& page, const uint32_t len, const byte* const data);
72 virtual void deleteByteArray(const id_type page);
73
74 private:
76
77 inline void processErrorCode(int errorCode, const id_type page);
78 }; // CustomStorageManager
79
80 // factory function
82 }
83}
84
Definition SpatialIndex.h:156
void processErrorCode(int errorCode, const id_type page)
CustomStorageManagerCallbacks callbacks
Definition CustomStorage.h:75
virtual void storeByteArray(id_type &page, const uint32_t len, const byte *const data)
virtual void deleteByteArray(const id_type page)
virtual void loadByteArray(const id_type page, uint32_t &len, byte **data)
Definition Tools.h:308
IStorageManager * returnCustomStorageManager(Tools::PropertySet &in)
Definition CustomStorage.h:34
int64_t id_type
Definition SpatialIndex.h:43
#define SIDX_DLL
Definition sidx_export.h:41
CustomStorageManagerCallbacks()
Definition CustomStorage.h:39