Prev | Next | |||
Object Views | Database |
Find and Filter Objects
When working with an oos::object_view you may want to find a certain object or you want to apply a function only for some of the objects in the view.
To achieve this we can use the oos::object_view::find_if method or we can use the global for_each_if() function. But how can we define or filter criterium?
First add some elements (persons) to the store and create the view. As you can see we've extended the person class with an age attribute.
If we want to find the person of age 25 we can achieve this by using the oos::object_view::find_if method. But first we have to create a variable holding the method of our object which should be used for comparation. Here it is person::age().
The call returns the first occurence of the object matching the expression or the end iterator.
If you want to apply a function to all objects matching a certain expression use oos::for_each_if() and use it in the following described way.
All persons whos age lays between 40 and 60 are printed.
Prev | Next | |||
Object Views | Database |