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