Data Access User Manual > Rogue Wave Views Data Access Common Framework > Data Sources and Gadgets > Data Sources > The Repository
 
The Repository
There are two ways in which a data source can be retrieved when its name is known:
*If the container in which it is located is known, the getObject member function can be used as follows:
IlvContainer* container;
...
IliDataSource* ds = (IliDataSource*)container->getObject(“EMP”);
*Alternatively, the IliRepository class provides static member functions that allow you to determine the data sources that are registered in the repository.
Each data source gadget is automatically registered in the repository when it is added to a container or manager. When it is removed from its holder, it is unregistered from the repository.
Here are the IliRepository rules by which a gadget can connect to a data source based on the data source name and on the location of the gadget:
*Same holder
If a data source is found in the same container as the gadget, it is chosen.
*Same scope class
Otherwise, if a data source is found in another container that belongs to the same scope class as the gadget container, it is chosen.
*Same container hierarchy
Otherwise, if a data source is found in another container that belongs to the same container hierarchy as the gadget container, it is chosen.
*Global scope
Otherwise, if a global data source is found, it is chosen.
*Otherwise, the look-up operation fails and the gadget does not connect to any data source.
Enumerating All Data Sources Accessible from the Repository
The following code fragment iterates through all the data source gadgets that are registered in a repository.
IlvInt count = IliRepository::GetDataSourcesCount();
for (IlInt i = 0; i < count; ++i) {
IliDataSource* ds = IliRepository::GetDataSource(i);
...
}
Finding a Data Source Using Its Name
The FindDataSource static member function can be used to retrieve a data source gadget using its name.
IlvGadget* g;
...
IliDataSource* ds;
ds = IliRepository::FindDataSource(“EMP”, g->getHolder());
Subscribing to a Given Data Source
The IliRepository supports a “subscription” mechanism. This mechanism allows you to specify a C++ function that should be called whenever a data source with a given name becomes available.
For more information, see the SubscribeToDataSource member function in the Rogue Wave Views Data Access Reference Manual.

Version 6.0
Copyright © 2015, Rogue Wave Software, Inc. All Rights Reserved.