1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
|
#pragma once
#include "ValueArray.h"
#include "Type.h"
namespace storm {
STORM_PKG(core.lang);
class SetBase;
class SerializeInfo;
/**
* Implements the template interface for the Set<> class in Storm.
*/
// Create types for unknown implementations.
Type *createSet(Str *name, ValueArray *params);
// Create the reference set type.
Type *createRefSet(Str *name, ValueArray *params);
/**
* Type for sets.
*/
class SetType : public Type {
STORM_CLASS;
public:
// Create.
STORM_CTOR SetType(Str *name, Type *k, Bool ref);
// Notifications.
virtual void STORM_FN notifyAdded(NameSet *to, Named *added);
protected:
// Load members.
virtual Bool STORM_FN loadAll();
private:
// Content type.
Type *k;
// Is the key hashed by reference?
Bool ref;
// Currently watching for, so that we know when to stop.
enum {
watchNone = 0x00,
watchSerialization = 0x01,
};
Nat watchFor;
// Helpers for creating instances.
static void createClass(void *mem);
static void createRefClass(void *mem);
static void copyClass(void *mem, SetBase *copy);
// Add the 'at' member.
void addMaybeAccess();
// Add serialization.
void addSerialization(SerializeInfo *info);
// Generate the 'write' function.
Function *writeFn(SerializedType *type, SerializeInfo *info);
// Generate the 'read' function.
Function *readCtor(SerializeInfo *info);
};
/**
* The set iterator type.
*/
class SetIterType : public Type {
STORM_CLASS;
public:
// Ctor.
SetIterType(Type *k);
protected:
// Lazy loading.
virtual Bool STORM_FN loadAll();
private:
// Content type.
Type *k;
};
}
|