Accessing Toolpack DB

From TBwiki
Revision as of 14:05, 30 May 2011 by Abrassard (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The CAF library provides DAOs (Data Access Objects) for all tables in the Toolpack configuration database.

Contents

Where to find these DAOs

These DAO objects are defined in the "tbcmc" source packages (tbcmc_2.5.89_common.tgz for example), under:

  • tb/inc/tbcaf/dao/oam

Pre-requisites to use these DAOs

To access the Toolpack database, an application needs to:

  • Attach to Toolpack OAM "CM" (configuration management), by binding an object of type CTBCAFServiceCmMgmtClient to the application
  • Connect to the database using object of type CTBCAFDb initialized using the DB connection string received on OnReloadConfig (see CTBCAFServiceCmMgmtClient)
  • Use appropriate DAO access object to query the desired table
  • Optionally use a custom SQL query string to query specific elements from a table

How to use the DAOs

  • Initialize the DAO access object that corresponds to the table you want to read from (CTBCAFOam_virtual_adapters_db_acc for example)
CTBCAFOam_virtual_adapters_db_acc   AccessVirtualAdapters;
AccessVirtualAdapters.Init( pConfigDb );
  • Use one of the DAO functions to retrieve one or multiple entries:
CTBCAFOam_virtual_adapters  VirtualAdapter = AccessVirtualAdapters.GetById( un32MyVirtualAdapterId );
std::vector<CTBCAFOam_virtual_adapters>  AllVirtualAdapters = AccessVirtualAdapters.GetAllBy_configuration_id( un32ConfigurationId );
  • Access the information from returned classes
VirtualAdapter.str_serial
VirtualAdapter.un32_last_upgrade_time
...

Example code

Here is some example code that show how to use these DAO objects

Personal tools