(component ComponentDefinition, class ComponentDefinitionClass, NameSpace string, NameSpaceImplementation string, ClassIdentifier string, BaseName string, outputFolder string, indentString string, stubIdentifier string, forceRecreation bool)
| 908 | |
| 909 | |
| 910 | func buildCPPStubClass(component ComponentDefinition, class ComponentDefinitionClass, NameSpace string, NameSpaceImplementation string, ClassIdentifier string, BaseName string, outputFolder string, indentString string, stubIdentifier string, forceRecreation bool) error { |
| 911 | outClassName := "C" + ClassIdentifier + class.ClassName |
| 912 | |
| 913 | StubHeaderFileName := path.Join(outputFolder, BaseName + stubIdentifier + "_" +strings.ToLower(class.ClassName)+".hpp"); |
| 914 | StubImplFileName := path.Join(outputFolder, BaseName + stubIdentifier + "_" + strings.ToLower(class.ClassName)+".cpp"); |
| 915 | if !forceRecreation && ( FileExists(StubHeaderFileName) || FileExists(StubImplFileName) ) { |
| 916 | log.Printf("Omitting recreation of Stub implementation for \"%s\"", outClassName) |
| 917 | return nil |
| 918 | } |
| 919 | |
| 920 | log.Printf("Creating \"%s\"", StubHeaderFileName) |
| 921 | stubheaderw, err := CreateLanguageFile(StubHeaderFileName, indentString) |
| 922 | if err != nil { |
| 923 | return err |
| 924 | } |
| 925 | stubheaderw.WriteCLicenseHeader(component, |
| 926 | fmt.Sprintf("This is the class declaration of %s", outClassName), |
| 927 | false) |
| 928 | |
| 929 | log.Printf("Creating \"%s\"", StubImplFileName) |
| 930 | stubimplw, err := CreateLanguageFile(StubImplFileName, indentString) |
| 931 | if err != nil { |
| 932 | return err |
| 933 | } |
| 934 | stubimplw.WriteCLicenseHeader(component, |
| 935 | fmt.Sprintf("This is a stub class definition of %s", outClassName), |
| 936 | false) |
| 937 | |
| 938 | stubheaderw.Writeln("") |
| 939 | stubheaderw.Writeln("#ifndef __%s_%s", strings.ToUpper(NameSpace), strings.ToUpper(class.ClassName)) |
| 940 | stubheaderw.Writeln("#define __%s_%s", strings.ToUpper(NameSpace), strings.ToUpper(class.ClassName)) |
| 941 | stubheaderw.Writeln("") |
| 942 | |
| 943 | stubheaderw.Writeln("#include \"%s_interfaces.hpp\"", BaseName) |
| 944 | if (component.isBaseClass(class)) { |
| 945 | stubheaderw.Writeln("#include <vector>") |
| 946 | stubheaderw.Writeln("#include <list>") |
| 947 | stubheaderw.Writeln("#include <memory>") |
| 948 | } |
| 949 | stubheaderw.Writeln("") |
| 950 | |
| 951 | if (!component.isBaseClass(class)) { |
| 952 | if (class.ParentClass == "") { |
| 953 | class.ParentClass = component.Global.BaseClassName |
| 954 | } |
| 955 | } |
| 956 | |
| 957 | if class.ParentClass != "" { |
| 958 | stubheaderw.Writeln("// Parent classes") |
| 959 | stubheaderw.Writeln("#include \"%s%s_%s.hpp\"", BaseName, stubIdentifier, strings.ToLower(class.ParentClass)) |
| 960 | stubheaderw.Writeln("#ifdef _MSC_VER") |
| 961 | stubheaderw.Writeln("#pragma warning(push)") |
| 962 | stubheaderw.Writeln("#pragma warning(disable : 4250)") |
| 963 | stubheaderw.Writeln("#endif") |
| 964 | } |
| 965 | stubheaderw.Writeln("") |
| 966 | |
| 967 | stubheaderw.Writeln("// Include custom headers here.") |
no test coverage detected