290 """ Does the actual work ... """
291 folderName = folder.fullPath().
split(
'/')[-1]
292 attrNames = [ps.name()
for ps
in folder.payloadSpecification()]
294 attrNames = filter(
lambda n: n
in attrIncludeList, attrNames)
295 elif attrExcludeList:
296 attrNames = filter(
lambda n: n
not in attrExcludeList, attrNames)
298 attrTypes = [ps.storageType().name()
for ps
in folder.payloadSpecification() \
299 if ps.name()
in attrNames]
300 attrNameTypes = zip(attrNames, attrTypes)
302 if not containerName:
303 containerName =
'L1Calo{0}Container'.format(folderName)
305 objectName =
'L1Calo{0}'.format(folderName)
309 mapping[
'CommandLine'] =
' '.join(sys.argv)
310 mapping[
'ContainerName'] = containerName
311 mapping[
'CONTAINERNAME'] = containerName.upper()
312 mapping[
'FolderName'] = folderName
314 mapping[
'ObjectName'] = objectName
315 mapping[
'EnumAttrSpecification'] =
', '.join([
'e{0}'.format(n)
for n
in attrNames])
316 mapping[
'FullFolderPath'] = folder.fullPath()
317 mapping[
'ClassDefMacro'] = \
318 'CLASS_DEF( {0}, {1}, 1 )'.format(containerName,
319 _cliddb.genClidFromName(containerName))
324 mapping[
'AttrList'] =
', '.join(
map(_toCamelCase, attrNames))
327 _writeToFile(
'{0}.h'.format(containerName), _container_header, mapping)
328 _writeToFile(
'{0}.cxx'.format(containerName), _container_src, mapping)
331 for not_needed
in (
'ContainerName',
'CONTAINERNAME',
'FolderName',
'folderName',
332 'EnumAttrSpecification',
'ClassDefMacro',
'DefineSpecificationList',
333 'AddSpecificationList',
'ReadSpecificationList',
'AttrList'):
334 del mapping[not_needed]
335 mapping[
'OBJECTNAME'] = objectName.upper()
336 mapping[
'AttrTypeNameList'] =
', '.join([
'{0} {1}'.format(
_mapToCpp(t),
_toCamelCase(n))
for (n,t)
in attrNameTypes])
343 _writeToFile(
'{0}.h'.format(objectName), _object_header, mapping)
344 _writeToFile(
'{0}.cxx'.format(objectName), _object_src, mapping)
348 'cont' : containerName,
350 'id' : str(uuid.uuid4()).
upper()
353 print '[I] Add the following to the selection.xml file:'
354 print ' <class name="{cont}" id="{id}" />'.format(**mapping)
355 print ' <class name="{cont}::const_iterator" />'.format(**mapping)
356 print ' <class name="{obj}" />'.format(**mapping)
358 print '[I] Add the following to the TrigT1CaloCalibConditionsDict.h file:'
359 print '#include "TrigT1CaloCalibConditions/{cont}.h"'.format(**mapping)
360 print '#include "TrigT1CaloCalibConditions/{obj}.h"'.format(**mapping)
362 print ' {cont}::const_iterator {cont}ConstInterator;'.format(**mapping)
366 parser = argparse.ArgumentParser(description=
'Create C++ classes that represent COOL database folders')
368 args = parser.parse_args()
370 if args.include
and args.exclude:
371 raise RuntimeError(
"Options --include and --exclude are mutually exclusive.")
373 db = _dbSvc.openDatabase(args.db)
374 folder = db.getFolder(args.folder)
377 args.exclude.split(
',')
if args.exclude
else None,
378 args.include.split(
',')
if args.include
else None,
379 args.containerName, args.objectName)