All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Public Attributes | Private Member Functions | List of all members
LArSoftUtils.SimpleServiceLoader Class Reference
Inheritance diagram for LArSoftUtils.SimpleServiceLoader:
ICARUSservices.ICARUSGeometryServiceGetter SBNDservices.SBNDGeometryServiceGetter

Public Member Functions

def __init__
 
def serviceKey
 
def load
 
def __call__
 
def expandClass
 
def __init__
 
def serviceKey
 
def load
 
def __call__
 
def expandClass
 

Public Attributes

 serviceClass
 
 interfaceClass
 
 headers
 
 libraries
 
 serviceDependencies
 
 purgeConfig
 
 addConfig
 

Private Member Functions

def _needsSpecialConfig
 
def _makeConfig
 
def _needsSpecialConfig
 
def _makeConfig
 

Detailed Description

Class storing the parameters needed to load a "simple" service.

So far a "simple" service is one that can be loaded with `loadSimpleService()`
allowing service provider dependencies and simple configuration adaptions.

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

Constructor & Destructor Documentation

def LArSoftUtils.SimpleServiceLoader.__init__ (   self,
  serviceClass,
  interfaceClass = None,
  headers = [],
  libraries = [],
  dependencies = [],
  purgeConfig = [],
  addConfig = {} 
)

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

185  ):
186  assert serviceClass is not None
187  self.serviceClass = serviceClass
188  self.interfaceClass = interfaceClass
189  self.headers = makeStringList(headers)
190  self.libraries = makeStringList(libraries)
191  self.serviceDependencies = makeStringList(dependencies)
192  self.purgeConfig = makeStringList(purgeConfig)
self.addConfig = addConfig
def LArSoftUtils.SimpleServiceLoader.__init__ (   self,
  serviceClass,
  interfaceClass = None,
  headers = [],
  libraries = [],
  dependencies = [],
  purgeConfig = [],
  addConfig = {} 
)

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

185  ):
186  assert serviceClass is not None
187  self.serviceClass = serviceClass
188  self.interfaceClass = interfaceClass
189  self.headers = makeStringList(headers)
190  self.libraries = makeStringList(libraries)
191  self.serviceDependencies = makeStringList(dependencies)
192  self.purgeConfig = makeStringList(purgeConfig)
self.addConfig = addConfig

Member Function Documentation

def LArSoftUtils.SimpleServiceLoader.__call__ (   self,
  manager 
)

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

248  def __call__(self, manager): return self.load(manager)
def LArSoftUtils.SimpleServiceLoader.__call__ (   self,
  manager 
)

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

248  def __call__(self, manager): return self.load(manager)
def LArSoftUtils.SimpleServiceLoader._makeConfig (   self,
  registry 
)
private

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

198  def _makeConfig(self, registry):
199  for configKey in ( self.serviceKey(), self.serviceKey() + "Service", ):
200  try:
201  config = registry.config(configKey)
202  break
203  except Exception: pass
204  else: config = None
205  if not config:
206  raise RuntimeError \
207  ("No configuration for service '{}'".format(self.serviceKey()))
208  # if
209  for key in self.purgeConfig: config.erase(key)
210  for key, value in self.addConfig.items(): config.put(key, str(value))
return config
static std::string format(PyObject *obj, unsigned int pos, unsigned int indent, unsigned int maxlen, unsigned int depth)
Definition: fclmodule.cxx:374
def LArSoftUtils.SimpleServiceLoader._makeConfig (   self,
  registry 
)
private

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

198  def _makeConfig(self, registry):
199  for configKey in ( self.serviceKey(), self.serviceKey() + "Service", ):
200  try:
201  config = registry.config(configKey)
202  break
203  except Exception: pass
204  else: config = None
205  if not config:
206  raise RuntimeError \
207  ("No configuration for service '{}'".format(self.serviceKey()))
208  # if
209  for key in self.purgeConfig: config.erase(key)
210  for key, value in self.addConfig.items(): config.put(key, str(value))
return config
static std::string format(PyObject *obj, unsigned int pos, unsigned int indent, unsigned int maxlen, unsigned int depth)
Definition: fclmodule.cxx:374
def LArSoftUtils.SimpleServiceLoader._needsSpecialConfig (   self)
private

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

196  def _needsSpecialConfig(self): return self.addConfig or self.purgeConfig
def LArSoftUtils.SimpleServiceLoader._needsSpecialConfig (   self)
private

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

196  def _needsSpecialConfig(self): return self.addConfig or self.purgeConfig
def LArSoftUtils.SimpleServiceLoader.expandClass (   self,
  attrName 
)

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

250  def expandClass(self, attrName):
251  classOrName = getattr(self, attrName)
252  if isinstance(classOrName, str):
253  classOrName = ROOTutils.getROOTclass(classOrName)
254  setattr(self, attrName, classOrName)
return classOrName
def LArSoftUtils.SimpleServiceLoader.expandClass (   self,
  attrName 
)

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

250  def expandClass(self, attrName):
251  classOrName = getattr(self, attrName)
252  if isinstance(classOrName, str):
253  classOrName = ROOTutils.getROOTclass(classOrName)
254  setattr(self, attrName, classOrName)
return classOrName
def LArSoftUtils.SimpleServiceLoader.load (   self,
  manager 
)

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

220  def load(self, manager):
221  # load the required service dependencies
222  dependencies = [
223  manager(dependency) for dependency in self.serviceDependencies
224  ]
225 
226  # load the required headers and libraries
227  for header in self.headers:
228  galleryUtils.SourceCode.loadHeaderFromUPS(header)
229  for library in self.libraries:
230  galleryUtils.SourceCode.loadLibrary(library)
231 
232  # loads the actual classes from ROOT
233  self.expandClass('serviceClass')
234  if self.interfaceClass is not None: self.expandClass('interfaceClass')
235 
236  # if we don't need a special configuration,
237  # we let loadSimpleService() find it
238  registry = manager.registry()
239  config = self._makeConfig(registry) if self._needsSpecialConfig() else None
240 
241  return loadSimpleService(
242  self.serviceClass, config=config, registry=registry,
243  interfaceClass=self.interfaceClass,
244  args=dependencies,
)
def LArSoftUtils.SimpleServiceLoader.load (   self,
  manager 
)

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

220  def load(self, manager):
221  # load the required service dependencies
222  dependencies = [
223  manager(dependency) for dependency in self.serviceDependencies
224  ]
225 
226  # load the required headers and libraries
227  for header in self.headers:
228  galleryUtils.SourceCode.loadHeaderFromUPS(header)
229  for library in self.libraries:
230  galleryUtils.SourceCode.loadLibrary(library)
231 
232  # loads the actual classes from ROOT
233  self.expandClass('serviceClass')
234  if self.interfaceClass is not None: self.expandClass('interfaceClass')
235 
236  # if we don't need a special configuration,
237  # we let loadSimpleService() find it
238  registry = manager.registry()
239  config = self._makeConfig(registry) if self._needsSpecialConfig() else None
240 
241  return loadSimpleService(
242  self.serviceClass, config=config, registry=registry,
243  interfaceClass=self.interfaceClass,
244  args=dependencies,
)
def LArSoftUtils.SimpleServiceLoader.serviceKey (   self)

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

214  def serviceKey(self):
215  source = (self.interfaceClass if self.interfaceClass else self.serviceClass)
216  if not isinstance(source, str): source = source.__name__
return source.replace('::', '.').split('.')[-1]
def LArSoftUtils.SimpleServiceLoader.serviceKey (   self)

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

214  def serviceKey(self):
215  source = (self.interfaceClass if self.interfaceClass else self.serviceClass)
216  if not isinstance(source, str): source = source.__name__
return source.replace('::', '.').split('.')[-1]

Member Data Documentation

LArSoftUtils.SimpleServiceLoader.addConfig

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

LArSoftUtils.SimpleServiceLoader.headers

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

LArSoftUtils.SimpleServiceLoader.interfaceClass

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

LArSoftUtils.SimpleServiceLoader.libraries

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

LArSoftUtils.SimpleServiceLoader.purgeConfig

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

LArSoftUtils.SimpleServiceLoader.serviceClass

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

LArSoftUtils.SimpleServiceLoader.serviceDependencies

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


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