289def create_classes_from_folder(folder, attrExcludeList, attrIncludeList, containerName, objectName):
290 """ Does the actual work ... """
291 folderName = folder.fullPath().
split(
'/')[-1]
292 attrNames = [ps.name() for ps in folder.payloadSpecification()]
293 if attrIncludeList:
294 attrNames = filter(lambda n: n in attrIncludeList, attrNames)
295 elif attrExcludeList:
296 attrNames = filter(lambda n: n not in attrExcludeList, attrNames)
297
298 attrTypes = [ps.storageType().name() for ps in folder.payloadSpecification() \
299 if ps.name() in attrNames]
300 attrNameTypes = zip(attrNames, attrTypes)
301
302 if not containerName:
303 containerName = 'L1Calo{0}Container'.format(folderName)
304 if not objectName:
305 objectName = 'L1Calo{0}'.format(folderName)
306
307
308 mapping = {}
309 mapping['CommandLine'] = ' '.join(sys.argv)
310 mapping['ContainerName'] = containerName
311 mapping['CONTAINERNAME'] = containerName.upper()
312 mapping['FolderName'] = folderName
313 mapping['folderName'] = _toCamelCase(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))
320
321 mapping['DefineSpecificationList'] = _createDefineSpecificationList(attrNameTypes)
322 mapping['AddSpecificationList'] = _createAddSpecificationList(attrNames)
323 mapping['ReadSpecificationList'] = _createReadSpecificationList(attrNameTypes)
324 mapping[
'AttrList'] =
', '.join(
map(_toCamelCase, attrNames))
325
326
327 _writeToFile('{0}.h'.format(containerName), _container_header, mapping)
328 _writeToFile('{0}.cxx'.format(containerName), _container_src, mapping)
329
330
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])
337 mapping['GetterList'] = _createGetterList(attrNameTypes)
338 mapping['SetterList'] = _createSetterList(attrNameTypes)
339 mapping['AttrDefinitions'] = _createAttrDefinitions(attrNameTypes)
340 mapping['AttrConstructorList'] = _createAttrConstructorList(attrNames)
341
342
343 _writeToFile('{0}.h'.format(objectName), _object_header, mapping)
344 _writeToFile('{0}.cxx'.format(objectName), _object_src, mapping)
345
346
347 mapping = {
348 'cont' : containerName,
349 'obj' : objectName,
350 'id' : str(uuid.uuid4()).
upper()
351 }
352 print
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)
357 print
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)
361 print
362 print ' {cont}::const_iterator {cont}ConstInterator;'.format(**mapping)
363
std::vector< std::string > split(const std::string &s, const std::string &t=":")