Chapter 2.3 - Provided Resoucres

The framework is there to simplify the whole development process of strategies. The central point to obtain resources is the object of the class RTBGlobal::MasterResourceControl (see rtbglobal/masterresourcecontrol.h) that you can obtain via the MasterResourceControl::Instance method. It is absolutely necessary to take a look about the provided methods. Here is a list of some interesting methods of this class:

createLogger()

If you want to tell anything about your internal state to the user, the only way to do so is to obtain a logger via this method. To get the logger, you will have to specify the section name of your component in the configuration file. The framework knows if (depends on the priority of your logging message and the priority threshold in the configuration file), how (depends on the specified log driver in the configuration file) and where (depends on the parameters for the log driver in the configuration file) to send your logging messages. See the logging API (logger/logger.h and logger/logdriverprototype.h for details about the concepts of logging used in the rtb team framework). It is a good idea to share one logger object for all client states / server states in the InternalClientSpecificRepository / SharedServerSpecificRepository.

Again, let's have a look at Brotfrucht's ClientSpecificRespoitory:

BFClientSpecificRepository::BFClientSpecificRepository() throw(StrategyException, \ 
	bad_exception): _hits(0), _logger(0),_shootingInterval(1000000000) {
  try {
    _logger=MasterResourceControl::Instance()->createLogger("BrotfruchtClient");
  }
  catch (RTBException& ex) {
    throw StrategyException("Could not obtain logger for the Brotfrucht client states: \ 
	"+ex.getMessage());
  }
}

As you can see, it's the repository's constructor. There, it is tried to get a Logger called "BrotfruchtClient" from the MasterResoucreControl and to store it in _logger (you will get a pointer to it by calling the getLogger() method). If that fails, an exception is thrown. For more information about the logger see the next chapter.

getConfigurationProperty()

With this method you can obtain values specified in the configuration file you need (for example parameters for your strategy).

setRuntimeProperty()/getRuntimeProperty()

These methods provide access to the global registry managed by the framework. You can use this facility to share information across different components / plugins of the framework. Remember that you have different kinds of repositories to do this in a better / type safe way.