535 def gen_files(pkg="", klass="", klass_type='object', fname='foo',
537 """Simple helper function to generate files based off some informations
538 @param pkg the name of the package holding the class we want to generate
539 @param klass the (fully qualified) name of the C++ class to generate
540 @param klass_type the type of class to generate (svc/tool/alg/object)
541 @param fname the filename to generate
542 @param ipkg the name of the package holding the interface of the class
543 @param iklass the name of the interface of the class we generate
546 hdr = getattr(Templates,
'%s_hdr_template'%klass_type)
547 cxx = getattr(Templates,
'%s_cxx_template'%klass_type)
548 except AttributeError
as err:
549 print (
"::: UNKNOWN klass_type [%s] !" % klass_type)
552 namespace_klass = klass.replace(
'::',
'_')
553 namespace_begin,namespace_end =
"",
""
554 if klass.count(
"::")>0:
555 nm = klass.split(
"::")[0]
556 klass = klass.split(
"::")[1]
557 namespace_begin = os.linesep +
"namespace %s {" % nm + os.linesep
558 namespace_end = os.linesep +
"} // namespace %s" % nm + os.linesep
561 guard =
"%s_%s_H" % (pkg.upper(), namespace_klass.upper())
568 namespace_begin=namespace_begin,
569 namespace_end=namespace_end,
570 copyright=Templates.copyright_template
572 fname = os.path.splitext(fname)[0]
574 o_hdr =
open(fname+
'.h',
'w')
575 o_hdr.writelines(hdr%d)
580 o_cxx =
open(fname+
'.cxx',
'w')
581 o_cxx.writelines(cxx%d)