Using an ObjectMold
This chapter will describe the use of flip::ObjectMold with the Flip framework.
Overview
The Flip framework offers a flip::ObjectMold class which allows to duplicate an object one or multiple times. This is typically used in a copy/paste system, or to duplicate objects.
Making the Mold
Copying or duplicating a Flip object can be done using a mold with the ObjectMold class.
The ObjectMold is made by constructing the mold from the flip Object to duplicate.
Internally, the mold will save all the informations of the object and object children, recursively. In particular, all containers and their elements are parsed recursively. However, flip::ObjectRef are not parsed recursively.
Together with the children datas, the ancestors datas are also saved, but in a much simpler format, called pre-destination. Pre-destination contains all the parents data, and recursively until the root class is reached. The parents data themselves contain the direct members data, but containers are not recursively parsed.
When using the flip::PasteBoard the mold is implicitely created internally.
Creating an Object from a Mold
The flip containers support the paste function which allows to create an object from a mold and put it in the container.
For Array :
iterator paste (iterator it, ObjectMold & mold); |
For Collection :
iterator paste (ObjectMold & mold); |
Those two functions returns an iterator to the created object from the mold.