collection.h
268 #define FIFTYONE_DEGREES_COLLECTION_RELEASE(c, i) { assert(!((i)->collection) || (c == (i)->collection)); c->release(i); };
int(* fiftyoneDegreesCollectionItemComparer)(void *state, fiftyoneDegreesCollectionItem *item, fiftyoneDegreesCollectionKey key, fiftyoneDegreesException *exception)
Compares two items and returns the difference between them for the purposes of a binary search of ord...
Definition: collection.h:364
bool fiftyoneDegreesCollectionGetIsMemoryOnly()
Determines if in memory collection methods have been compiled so they are fully optimized.
fiftyoneDegreesCollection * source
The source collection used to load items into the cache.
Definition: collection.h:454
Type of collection where items are cached as they are used.
Definition: collection.h:453
fiftyoneDegreesCollectionFileRead read
Read method used to read an item from file at an offset or index.
Definition: collection.h:443
Collection header structure which defines the size and location of the collection data.
Definition: collection.h:278
fiftyoneDegreesCache * cache
Loading cache to use as data source.
Definition: collection.h:456
fiftyoneDegreesFileOffsetUnsigned startPosition
Start position in the data file of the entities.
Definition: collection.h:279
const fiftyoneDegreesCollection * collection
Collection the item came from which may not have been set.
Definition: collection.h:317
Explains to a collection how to properly extract the requested value.
Definition: collectionKey.h:63
fiftyoneDegreesCollectionHeader fiftyoneDegreesCollectionHeaderFromFile(FILE *file, uint32_t elementSize, bool isCount)
Reads the 4 bytes at the current reader position and configures the collection header.
fiftyoneDegreesCollection * collection
The generic collection.
Definition: collection.h:439
int32_t fiftyoneDegreesCollectionGetInteger32(const fiftyoneDegreesCollection *collection, uint32_t indexOrOffset, fiftyoneDegreesException *exception)
Returns a 32 bit integer from collections that provide such values.
bool(* fiftyoneDegreesCollectionIterateMethod)(void *state, uint32_t key, void *data)
Method used to iterate over data held in a collection.
Definition: collection.h:392
Used to store a handle to the underlying item that could be used to release the item when it's finish...
Definition: collection.h:309
void(* fiftyoneDegreesCollectionReleaseMethod)(fiftyoneDegreesCollectionItem *item)
Releases the item so that the collection can free the memory or take other actions when the caller no...
Definition: collection.h:375
fiftyoneDegreesFileHandle * fiftyoneDegreesCollectionReadFilePosition(const fiftyoneDegreesCollectionFile *file, uint32_t offset, fiftyoneDegreesException *exception)
Get a handle from the file pool associated with the collection and position the file handle at the of...
Used to read data from memory in a similar manner to a file handle.
Definition: memory.h:54
Cache structure to store the root of the red black tree and a list of allocated cache nodes.
Definition: cache.h:187
fiftyoneDegreesCollectionFreeMethod freeCollection
Frees collection and all items retrieved from the collection will become invalid.
Definition: collection.h:409
void * fiftyoneDegreesCollectionReadFileVariable(const fiftyoneDegreesCollectionFile *file, fiftyoneDegreesData *data, const fiftyoneDegreesCollectionKey *key, void *initial, fiftyoneDegreesException *exception)
Reads a variable size item from the file where the initial bytes can be used to calculate the size of...
fiftyoneDegreesCollection * fiftyoneDegreesCollectionCreateFromFile(FILE *file, fiftyoneDegreesFilePool *reader, const fiftyoneDegreesCollectionConfig *config, fiftyoneDegreesCollectionHeader header, fiftyoneDegreesCollectionFileRead read)
Creates a collection from the file handle at the current position in the file.
uint32_t fiftyoneDegreesFileOffsetUnsigned
Type for collection start offset (in file).
Definition: fileOffset.h:61
uint32_t count
The number of items, or 0 if not available.
Definition: collection.h:417
Type of collection where the collection is streamed from file.
Definition: collection.h:438
uint32_t capacity
Number of items the cache should store, 0 for no cache.
Definition: collection.h:291
byte * firstByte
The first byte in memory of the collection.
Definition: collection.h:429
bool loaded
Collection is loaded entirely into memory.
Definition: collection.h:290
fiftyoneDegreesFileOffset offset
Offset to the collection in the source data structure.
Definition: collection.h:442
Data structure used for reusing memory which may have been allocated in a previous operation.
Definition: data.h:101
uint32_t count
Number of entities in the collection.
Definition: collection.h:281
fiftyoneDegreesCollectionHeader fiftyoneDegreesCollectionHeaderFromMemory(fiftyoneDegreesMemoryReader *reader, uint32_t elementSize, bool isCount)
Reads the 4 bytes at the current reader position and configures the collection header.
void * handle
A handle that relates to the data.
Definition: collection.h:311
void * memoryToFree
Memory to free when freeing the collection, or NULL if no memory to free.
Definition: collection.h:431
fiftyoneDegreesFilePool * reader
Reader used to load items into the cache, or NULL if no cache.
Definition: collection.h:440
const char * typeName
Name of collection type (vtable).
Definition: collection.h:421
long fiftyoneDegreesCollectionBinarySearch(const fiftyoneDegreesCollection *collection, fiftyoneDegreesCollectionItem *item, fiftyoneDegreesCollectionIndexOrOffset lowerKey, fiftyoneDegreesCollectionIndexOrOffset upperKey, const fiftyoneDegreesCollectionKeyType *keyType, void *state, fiftyoneDegreesCollectionItemComparer comparer, fiftyoneDegreesException *exception)
Where a collection is fixed width and contains an ordered list of items this method is used to perfor...
uint16_t concurrency
Expected number of concurrent requests, 1 or greater.
Definition: collection.h:293
long fiftyoneDegreesFileOffset
Type for file offset in API.
Definition: fileOffset.h:69
uint32_t elementSize
The size of each entry, or 0 if variable length.
Definition: collection.h:418
fiftyoneDegreesCollectionGetMethod get
Gets an entry into the item provided.
Definition: collection.h:403
void *(* fiftyoneDegreesCollectionGetMethod)(const fiftyoneDegreesCollection *collection, const fiftyoneDegreesCollectionKey *key, fiftyoneDegreesCollectionItem *item, fiftyoneDegreesException *exception)
Gets an item from the collection.
Definition: collection.h:331
void * state
Pointer to data for memory, cache or file.
Definition: collection.h:413
Collection configuration structure which defines how the collection should be created by the create m...
Definition: collection.h:289
void(* fiftyoneDegreesCollectionFreeMethod)(fiftyoneDegreesCollection *collection)
Frees all the memory and handles associated with the collection.
Definition: collection.h:382
Location of the item within the Collection.
Definition: collectionKey.h:52
Structure used to represent a 51Degrees exception and passed into methods that might generate excepti...
Definition: exceptions.h:111
Explains to a collection (or cache) what the consumer is looking for.
Definition: collectionKey.h:72
Type of collection where the collection is held in continuous memory.
Definition: collection.h:427
fiftyoneDegreesCollection * fiftyoneDegreesCollectionCreateFromMemory(fiftyoneDegreesMemoryReader *reader, fiftyoneDegreesCollectionHeader header)
Creates the collection from a memory reader where the collection maps to the memory allocated to the ...
Stack of handles used to read data from a single source file.
Definition: file.h:229
uint32_t length
Length in bytes of all the entities.
Definition: collection.h:280
All the shared methods and fields required by file, memory and cached collections.
Definition: collection.h:402
fiftyoneDegreesData data
Item data including allocated memory.
Definition: collection.h:310
fiftyoneDegreesCollectionReleaseMethod release
Releases the item handle.
Definition: collection.h:407
byte * lastByte
The last byte in memory of the collection.
Definition: collection.h:430
void *(* fiftyoneDegreesCollectionFileRead)(const fiftyoneDegreesCollectionFile *collection, const fiftyoneDegreesCollectionKey *key, fiftyoneDegreesData *data, fiftyoneDegreesException *exception)
Reads the item from the underlying data file.
Definition: collection.h:347
void * fiftyoneDegreesCollectionReadFileFixed(const fiftyoneDegreesCollectionFile *file, const fiftyoneDegreesCollectionKey *key, fiftyoneDegreesData *data, fiftyoneDegreesException *exception)
Used with collections where each item is a fixed number of bytes recorded in elementSize.
fiftyoneDegreesCollection * collection
The generic collection.
Definition: collection.h:428
uint32_t size
Number of bytes in the source data structure containing the collection's data.
Definition: collection.h:419
