Using data sources for initializing applications
In order to refer to one or more data sources in an application, one may define a configuration or ini-file, which is used for initializing the application. When the application has been initialized, all data sources defined in different sections in the ini-file or as complex xml - options in the configuration file can easily be accessed.
By means of the configuration file, i.e. by defining data sources within the configuration or ini-file, one may also decide, whether the database is accessed locally or via a client server connection.
Of course, all what you can do with an application configuration, one may also program step by step in your application, i.e. application configurations are just a mean for making life easier.
The application configuration may also refer to a data source catalog, in which case data sources need not to be defined explicitly in the configuration file, but rather in a central data catalog, which might be defined with the ObjectCommander tool or by an OSI script file.
int main ( int argc, char *argv[] ) {
if ( argc < 2 ) THROW
Application::initialize(argv[1],argv[0],ConsoleApplication);
// Database1 must be a section in the configuration
DataSource ds("Database1");
ds.openDatabase(); // opens dictionary and database
Property persons(ds.database,"Person::Persons",Update);
// ... now you may access all person object instances
}
Section names in the configuration file are case insensitive in some environments. When refering to data source definitions in the data catalog, data source names are case sensitive. It is suggested, using unique names and refer always to the correct spelling, also, when this is not necessary.