Prev | Next | |||
Object Relations | Expressions |
Open a view
In most cases we want to iterate over all objects of a certain type. How can we achieve this? We open a view for the type we want to inspect.
Again we use our little person class and insert some persons into our store.
Than we create a view with the oos::object_view class. This class takes as the template parameter the desired class type. Then we can use the view like a STL list containing oos::object_ptr of our desired type.
But this class can to somethig more for us. If we have a hierarchy of classes, we can create a view of the base type and easily iterate overall sub-types.
Look at the next example. We have a hierachy with the person class as base class and inherited from that we have classes student and employee. And again we create a view of type person to access all objects of type person including sub-types student and employee.
Prev | Next | |||
Object Relations | Expressions |