All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Public Member Functions | Public Attributes | Static Public Attributes | List of all members
LArSoftUtils.ServiceManagerInstance Class Reference
Inheritance diagram for LArSoftUtils.ServiceManagerInstance:
LArSoftUtils.ServiceManagerInterface LArSoftUtils.ServiceManagerInterface ICARUSservices.ICARUSserviceManagerClass SBNDservices.SBNDserviceManagerClass

Classes

class  ConfigurationInfo
 

Public Member Functions

def __init__
 
def registry
 
def registerLoader
 
def get
 
def defaultConfiguration
 
def setConfiguration
 
def setup
 
def __init__
 
def registry
 
def registerLoader
 
def get
 
def defaultConfiguration
 
def setConfiguration
 
def setup
 
- Public Member Functions inherited from LArSoftUtils.ServiceManagerInterface
def registry
 
def loaders
 
def loaded
 
def supported
 
def registerLoader
 
def get
 
def __call__
 
def registry
 
def loaders
 
def loaded
 
def supported
 
def registerLoader
 
def get
 
def __call__
 

Public Attributes

 manager
 
 configuration
 

Static Public Attributes

dictionary StandardLoadingTable
 

Detailed Description

A service manager with a lazy setup.

Definition at line 396 of file icarusalg/icarusalg/gallery/helpers/python/LArSoftUtils.py.

Constructor & Destructor Documentation

def LArSoftUtils.ServiceManagerInstance.__init__ (   self)
def LArSoftUtils.ServiceManagerInstance.__init__ (   self)

Definition at line 446 of file sbndcode/sbndcode/gallery/python/LArSoftUtils.py.

447  def __init__(self):
448  self.manager = None
449  self.configuration = None

Member Function Documentation

def LArSoftUtils.ServiceManagerInstance.defaultConfiguration (   self)

Definition at line 477 of file icarusalg/icarusalg/gallery/helpers/python/LArSoftUtils.py.

478  def defaultConfiguration(self): return None
def LArSoftUtils.ServiceManagerInstance.defaultConfiguration (   self)

Definition at line 477 of file sbndcode/sbndcode/gallery/python/LArSoftUtils.py.

478  def defaultConfiguration(self): return None
def LArSoftUtils.ServiceManagerInstance.get (   self,
  serviceKey,
  interfaceClass = None 
)
Return (and load first when needed) the specified service.

The service can be specified by name or by class.
In the former case, if the service is not already configured, an exception
will be raised.

Definition at line 465 of file sbndcode/sbndcode/gallery/python/LArSoftUtils.py.

466  def get(self, serviceKey, interfaceClass = None):
467  """Return (and load first when needed) the specified service.
468 
469  The service can be specified by name or by class.
470  In the former case, if the service is not already configured, an exception
471  will be raised.
472  """
473  if not self.manager: self.setup()
return self.manager(serviceKey)
def LArSoftUtils.ServiceManagerInstance.get (   self,
  serviceKey,
  interfaceClass = None 
)
Return (and load first when needed) the specified service.

The service can be specified by name or by class.
In the former case, if the service is not already configured, an exception
will be raised.

Definition at line 465 of file icarusalg/icarusalg/gallery/helpers/python/LArSoftUtils.py.

466  def get(self, serviceKey, interfaceClass = None):
467  """Return (and load first when needed) the specified service.
468 
469  The service can be specified by name or by class.
470  In the former case, if the service is not already configured, an exception
471  will be raised.
472  """
473  if not self.manager: self.setup()
return self.manager(serviceKey)
def LArSoftUtils.ServiceManagerInstance.registerLoader (   self,
  serviceKey,
  loader 
)
Registers a service provider loader, that can then be invoked to create
the service.

It returns the service manager.

Definition at line 455 of file sbndcode/sbndcode/gallery/python/LArSoftUtils.py.

456  def registerLoader(self, serviceKey, loader):
457  """Registers a service provider loader, that can then be invoked to create
458  the service.
459 
460  It returns the service manager.
461  """
return self.manager.registerLoader(serviceKey, loader)
def LArSoftUtils.ServiceManagerInstance.registerLoader (   self,
  serviceKey,
  loader 
)
Registers a service provider loader, that can then be invoked to create
the service.

It returns the service manager.

Definition at line 455 of file icarusalg/icarusalg/gallery/helpers/python/LArSoftUtils.py.

456  def registerLoader(self, serviceKey, loader):
457  """Registers a service provider loader, that can then be invoked to create
458  the service.
459 
460  It returns the service manager.
461  """
return self.manager.registerLoader(serviceKey, loader)
def LArSoftUtils.ServiceManagerInstance.registry (   self)
Returns the service registry.

Definition at line 450 of file icarusalg/icarusalg/gallery/helpers/python/LArSoftUtils.py.

451  def registry(self):
452  """Returns the service registry."""
return self.manager.registry()
def LArSoftUtils.ServiceManagerInstance.registry (   self)
Returns the service registry.

Definition at line 450 of file sbndcode/sbndcode/gallery/python/LArSoftUtils.py.

451  def registry(self):
452  """Returns the service registry."""
return self.manager.registry()
def LArSoftUtils.ServiceManagerInstance.setConfiguration (   self,
  configFile,
  serviceTable = None 
)
Sets which configuration to use for setup.

If `serviceTable` is not `None`, a new configuration is created with the
service table as `serviceTable`, and `configPath` is included in that
configuration (presumably to define `serviceTable`).

If `serviceTable` is `None` instead, the configuration file in
`configPath` is included directly, and it is assumed that it already
properly defines a `services` table.

Definition at line 479 of file sbndcode/sbndcode/gallery/python/LArSoftUtils.py.

480  def setConfiguration(self, configFile, serviceTable = None):
481  """Sets which configuration to use for setup.
482 
483  If `serviceTable` is not `None`, a new configuration is created with the
484  service table as `serviceTable`, and `configPath` is included in that
485  configuration (presumably to define `serviceTable`).
486 
487  If `serviceTable` is `None` instead, the configuration file in
488  `configPath` is included directly, and it is assumed that it already
489  properly defines a `services` table.
490  """
491  assert configFile is not None
492  self.configuration \
= ServiceManagerInstance.ConfigurationInfo(configFile, serviceTable)
def LArSoftUtils.ServiceManagerInstance.setConfiguration (   self,
  configFile,
  serviceTable = None 
)
Sets which configuration to use for setup.

If `serviceTable` is not `None`, a new configuration is created with the
service table as `serviceTable`, and `configPath` is included in that
configuration (presumably to define `serviceTable`).

If `serviceTable` is `None` instead, the configuration file in
`configPath` is included directly, and it is assumed that it already
properly defines a `services` table.

Definition at line 479 of file icarusalg/icarusalg/gallery/helpers/python/LArSoftUtils.py.

480  def setConfiguration(self, configFile, serviceTable = None):
481  """Sets which configuration to use for setup.
482 
483  If `serviceTable` is not `None`, a new configuration is created with the
484  service table as `serviceTable`, and `configPath` is included in that
485  configuration (presumably to define `serviceTable`).
486 
487  If `serviceTable` is `None` instead, the configuration file in
488  `configPath` is included directly, and it is assumed that it already
489  properly defines a `services` table.
490  """
491  assert configFile is not None
492  self.configuration \
= ServiceManagerInstance.ConfigurationInfo(configFile, serviceTable)
def LArSoftUtils.ServiceManagerInstance.setup (   self)
Prepares for service provider access in python/Gallery.

Definition at line 495 of file icarusalg/icarusalg/gallery/helpers/python/LArSoftUtils.py.

496  def setup(self):
497  """Prepares for service provider access in python/Gallery."""
498 
499  if self.manager is not None: return self.manager
500 
501  #
502  # configuration "file"
503  #
504  configurationInfo = self.defaultConfiguration() \
505  if self.configuration is None else self.configuration
506 
507  # if assertion fails, then `setConfiguration()` was not correctly called.
508  assert self.configuration.isValid()
509 
510  if configurationInfo.fullConfig():
511  config = configurationInfo.configPath
512  else:
514  '#include "{configPath}"'
515  '\n'
516  '\nservices: @local::{serviceTable}'
517  '\n'
518  .format(
519  configPath=configurationInfo.configPath,
520  serviceTable=configurationInfo.serviceTable
521  )
522  )
523  # if ... else
524 
525  #
526  # prepare the service registry and manager
527  #
528  self.manager = ServiceManagerClass \
529  (config, loadingTable=ServiceManagerInstance.StandardLoadingTable)
530 
531  #
532  # register the services we know about;
533  # some are already known
534  # (`LArSoftUtils.ServiceManagerClass.StandardLoadingTable`), including
535  # 'Geometry', 'LArProperties', 'DetectorClocks' and 'DetectorProperties',
536  # but se override the former with our flavor of it
537  #
538 
539  return self.manager
static std::string format(PyObject *obj, unsigned int pos, unsigned int indent, unsigned int maxlen, unsigned int depth)
Definition: fclmodule.cxx:374
def LArSoftUtils.ServiceManagerInstance.setup (   self)
Prepares for service provider access in python/Gallery.

Definition at line 495 of file sbndcode/sbndcode/gallery/python/LArSoftUtils.py.

496  def setup(self):
497  """Prepares for service provider access in python/Gallery."""
498 
499  if self.manager is not None: return self.manager
500 
501  #
502  # configuration "file"
503  #
504  configurationInfo = self.defaultConfiguration() \
505  if self.configuration is None else self.configuration
506 
507  # if assertion fails, then `setConfiguration()` was not correctly called.
508  assert self.configuration.isValid()
509 
510  if configurationInfo.fullConfig():
511  config = configurationInfo.configPath
512  else:
514  '#include "{configPath}"'
515  '\n'
516  '\nservices: @local::{serviceTable}'
517  '\n'
518  .format(
519  configPath=configurationInfo.configPath,
520  serviceTable=configurationInfo.serviceTable
521  )
522  )
523  # if ... else
524 
525  #
526  # prepare the service registry and manager
527  #
528  self.manager = ServiceManagerClass \
529  (config, loadingTable=ServiceManagerInstance.StandardLoadingTable)
530 
531  #
532  # register the services we know about;
533  # some are already known
534  # (`LArSoftUtils.ServiceManagerClass.StandardLoadingTable`), including
535  # 'Geometry', 'LArProperties', 'DetectorClocks' and 'DetectorProperties',
536  # but se override the former with our flavor of it
537  #
538 
539  return self.manager
static std::string format(PyObject *obj, unsigned int pos, unsigned int indent, unsigned int maxlen, unsigned int depth)
Definition: fclmodule.cxx:374

Member Data Documentation

LArSoftUtils.ServiceManagerInstance.configuration

Definition at line 448 of file icarusalg/icarusalg/gallery/helpers/python/LArSoftUtils.py.

LArSoftUtils.ServiceManagerInstance.manager

Definition at line 447 of file icarusalg/icarusalg/gallery/helpers/python/LArSoftUtils.py.

dictionary LArSoftUtils.ServiceManagerInstance.StandardLoadingTable
static
Initial value:
1 = {
2 
3  'Geometry': GeometryServiceGetter(),
4 
5  'LArProperties': SimpleServiceLoader(
6  "detinfo::LArPropertiesStandard",
7  interfaceClass="detinfo::LArProperties",
8  headers = 'lardataalg/DetectorInfo/LArPropertiesStandardTestHelpers.h',
9  libraries = 'lardataalg_DetectorInfo',
10  ),
11 
12  'DetectorClocks': SimpleServiceLoader(
13  "detinfo::DetectorClocksStandard",
14  interfaceClass="detinfo::DetectorClocks",
15  headers = 'lardataalg/DetectorInfo/DetectorClocksStandardTestHelpers.h',
16  libraries = 'lardataalg_DetectorInfo',
17  ),
18 
19  'DetectorProperties': SimpleServiceLoader(
20  "detinfo::DetectorPropertiesStandard",
21  interfaceClass="detinfo::DetectorProperties",
22  headers = 'lardataalg/DetectorInfo/DetectorPropertiesStandardTestHelpers.h',
23  libraries = 'lardataalg_DetectorInfo',
24  dependencies = [ 'Geometry', 'LArProperties' ],
25  ),
26 
27  }

Definition at line 401 of file icarusalg/icarusalg/gallery/helpers/python/LArSoftUtils.py.


The documentation for this class was generated from the following files: