CMS 3D CMS Logo

Functions | Variables

python::generateWrappers Namespace Reference

Functions

def declareCondWrappers
def declareXMLCondWrappers
def generateBuildFile
def generateClassesHeader
def generateDict
def generateWrapper
def getClasses
def guessClasses
def guessPackage
def walkPlugins

Variables

string wrapperDeclarationFooter
string wrapperDeclarationHeader

Function Documentation

def python::generateWrappers::declareCondWrappers (   package)

Definition at line 72 of file generateWrappers.py.

00073                                 :
00074     _newch = file('../../CondFormats/'+package+'/src/classes_new.h','w')
00075     for line in file('../../CondFormats/'+package+'/src/classes.h'):
00076         if (line.find('wrapper declarations')>0) : break
00077         _newch.write(line)
00078     _newch.write(wrapperDeclarationHeader)
00079     _n=0
00080     for cl in getClasses(package):
00081         _newch.write('      pool::Ptr<'+cl+' > p'+str(_n)+';\n')
00082         _newch.write('      cond::DataWrapper<'+cl+' > dw'+str(_n)+';\n')
00083         _n=_n+1
00084     _newch.write(wrapperDeclarationFooter)
00085     _newch.close()

def python::generateWrappers::declareXMLCondWrappers (   package)

Definition at line 86 of file generateWrappers.py.

00087                                    :
00088     _wrapperComment = '<-- wrapper declarations -->\n'
00089     _newxml = file('../../CondFormats/'+package+'/src/classes_def_new.xml','w')
00090     for line in file('../../CondFormats/'+package+'/src/classes_def.xml'):
00091         if (line.find('wrapper declarations')>0) : break
00092         _newch.write(line)
00093     _newch.write_(wrapperComment)
00094     for cl in getClasses(package):
00095         _newch.write(' <class name="pool::Ptr<'+cl+' >"/>\n')
00096         _newch.write(' <class name="cond::DataWrapper<'+cl+' >"/>\n')
00097     _newch.close()
00098 
00099 
00100 

def python::generateWrappers::generateBuildFile (   package,
  classes 
)

Definition at line 101 of file generateWrappers.py.

00102                                        :
00103     f = file('plugins/BuildFile','w')
00104     f.seek(0,2)
00105     s = string.Template(buildfileTemplate)
00106     for classname in classes:
00107         f.write(s.substitute(_PACKAGE_=package, _CLASS_NAME_=classname).replace('-',''))

def python::generateWrappers::generateClassesHeader (   package)

Definition at line 33 of file generateWrappers.py.

00034                                   :
00035     _header = '/* Condition Objects'
00036     _footer = '\n */\n\n#include "CondFormats/Common/interface/PayloadWrapper.h"\n\n'
00037     _leader = '\n * '
00038 
00039     _classes = guessClasses()
00040     
00041     _newch = file('../../CondFormats/'+package+'/src/classes_new.h','w')
00042     _newch.write(_header)
00043     for cl in _classes :
00044         _newch.write(_leader+cl)
00045     _newch.write(_footer)
00046     for line in file('../../CondFormats/'+package+'/src/classes.h'):
00047         _newch.write(line)
00048     _newch.close()

def python::generateWrappers::generateDict (   package)

Definition at line 117 of file generateWrappers.py.

00118                          :
00119     os.system('cd ../../;cvs co CondFormats/'+package)
00120     declareCondWrappers(package)
00121     declareXMLCondWrappers(package)
00122 
def python::generateWrappers::generateWrapper (   package,
  classes 
)

Definition at line 108 of file generateWrappers.py.

00109                                      :
00110     s = string.Template(wrapperTemplate)
00111     for classname in classes:
00112         f = file('plugins/'+classname+'PyWrapper.cc','w')
00113         print "generating file:", f.name
00114         f.write(s.substitute(_PACKAGE_=package, _CLASS_NAME_=classname, _HEADER_FILE_=classname))
00115         f.close()
00116           

def python::generateWrappers::getClasses (   package)

Definition at line 49 of file generateWrappers.py.

00050                         :
00051     _header = 'Condition Objects'
00052     _ret = []
00053     _ch = file('../../CondFormats/'+package+'/src/classes.h')
00054     if (_ch.readline().find(_header)<0) :
00055         print 'comment header not found in '+package
00056         return _ret
00057     for line in _ch:
00058         if (line.find('*/')>0) : break
00059         _ret.append(line[3:].rstrip())
00060     _ch.close()
00061     return _ret

def python::generateWrappers::guessClasses ( )

Definition at line 25 of file generateWrappers.py.

00026                    :
00027     _ret = []
00028     lines = ( line for line in file('src/plugin.cc') if line[0:3]=='REG')
00029     for line in lines:
00030         _ret.append(line[line.find(',')+1:line.find(')')])
00031     return _ret
00032 
# generate the comment in classes.h
def python::generateWrappers::guessPackage ( )

Definition at line 17 of file generateWrappers.py.

00018                    :
00019     lines = ( line for line in file('src/plugin.cc')
00020               if (line.find('CondFormats')>0 and line.find('DataRecord')<0)
00021     )
00022     _f = lines.next()
00023     _f = _f[_f.find('CondFormats/')+len('CondFormats/'):]
00024     return _f[:_f.find('/')]
 
def python::generateWrappers::walkPlugins (   a)

Definition at line 7 of file generateWrappers.py.

00008                   :
00009     for dir in os.listdir('.'):
00010         if(dir.find('Plugins')<0) : continue
00011         os.chdir(dir)
00012         a.act()
00013         os.chdir('../')
00014 
00015 
00016 # All those below run in CondCore/XyzPlugin directory


Variable Documentation

Initial value:
00001 """
00002    };
00003 }
00004 """

Definition at line 67 of file generateWrappers.py.

Initial value:
00001 """
00002 // wrapper declarations
00003 namespace {
00004    struct wrappers {
00005 """

Definition at line 62 of file generateWrappers.py.