Пример #1
0
 /**
  * Attempts to return a concrete DTtemp_Driver instance based
  * on $driver.
  *
  * @param $driver   The type of concrete Kronolith_Driver subclass to return.
  *                  This is based on the sensor driver ($driver). The
  *                  code is dynamically included.
  *
  * @param $params   (optional) A hash containing any additional
  *                  configuration or connection parameters a subclass
  *                  might need.
  *
  * @return          The newly created concrete Kronolith_Driver instance, or false
  *                  on error.
  */
 function &factory($driver, $params = array())
 {
     $basename = DTtemp_Driver::makeDriverFileName($driver);
     require_once $basename;
     $class = 'DTtemp_Driver_' . $driver;
     if (class_exists($class)) {
         return new $class($params);
     } else {
         Utils::fatal(new PEAR_Error(sprintf(_("Unable to load the definition of %s."), $class)), __FILE__, __LINE__);
     }
 }