PublishedObjectArray

The PublishedObjectArray class template allows to serialize an array of PropertyPublisher.

A Serializer is not able to directly handle object arrays but this class does the task automatically by managing the internal list of publications.

The life-time of the objects is automatically handled by the internal container.

Constructors

this
this()

Destructor

A destructor is present on this object, but not explicitly documented in the source.

Members

Functions

addItem
ItemClass addItem(A a)

Instantiates and returns a new item.

clear
void clear()

Clears the internal container and destroys the items.

count
uint count()
void count(uint aValue)

Sets or gets the item count.

deleteItem
void deleteItem(T t)

Removes and destroys an item from the internal container.

items
ItemClass[] items()

Provides an access to the items.

opApply
int opApply(int delegate(ItemClass) dg)

Support for iterating the items with foreach().

opApplyReverse
int opApplyReverse(int delegate(ItemClass) dg)

Support for iterating the items with foreach_reverse().

opBinaryRight
const(ItemClass)* opBinaryRight(auto ref K key)

Returns a pointer to the item whose the member that matches to the parameter passed as key during instanciation as the same value as key.

opIndex
ItemClass opIndex(size_t i)

Support for accessing an indexed item with [].

opSlice
ItemClass[] opSlice()

Same as items().

opSlice
ItemClass[] opSlice(size_t lo, size_t hi)

Same as items() but with bounds.

updateAA
void updateAA()

Updates the associative array that exists when the member passed as key during the instanciation is not empty.

Inherited Members

From PropertyPublisher

publicationCount
size_t publicationCount()

Returns the count of descriptor this class publishes.

publicationFromName
GenericDescriptor* publicationFromName(const(char)[] name)

Returns a pointer to a descriptor according to its name. Similar to the publication() function template excepted that the result type has not to be specified.

publicationFromIndex
GenericDescriptor* publicationFromIndex(size_t index)

Returns a pointer the index-th descriptor. Index must be within the [0 .. publicationCount] range.

declarator
Object declarator()
void declarator(Object value)

Pointer to the object that has created the descriptor leading to this PropertyPublisher instance.

Examples

1 class Item : PropertyPublisher
2 {
3     mixin PropertyPublisherImpl;
4     mixin inheritedDtor;
5     @SetGet uint _a, _b, _c;
6     // a default ctor is needed.
7     this(){collectPublications!Item;}
8     this(uint a, uint b, uint c)
9     {
10         _a = a; _b = b; _c = c;
11         collectPublications!Item;
12     }
13 }
14 
15 auto itemArray = construct!(PublishedObjectArray!Item);
16 itemArray.addItem(1, 2, 3);
17 itemArray.addItem(4, 5, 6);
18 // serializes the object array to a file
19 version(none) publisherToFile(itemArray, "backup.txt");
20 destruct(itemArray);

Meta