Separate Code Generation header and implementation

I'm learning Enterprise Architect and so far it seems like a nice tool. That said, I am having a problem with code generation. I'd like generated code to be separated such that the class declaration is in a .h file and implementation is in .cpp files (template classes aside). For example, I'd expect generated code for some class, Foo, to look like:

Foo.h

class Foo
{
    public:
        Foo();
        int GetSomeInt();
        void SetSomeInt(int a);

    private:
        int someInt;
}

Foo.cpp

Foo::Foo()
{
}

int Foo::GetSomeInt()
{
}


void Foo::SetSomeInt(int a)
{
}

Instead I get a header file with all of the above code in it, which will obviously cause problems later when I try to use Foo in multiple files that all get linked together. How can I tell the tool that I want separate files for class declaration and implementation?


After some further experimentation trying to respond to comments, I discovered at least part of my problem. The original modeled class I was trying to generate code for was a template class. Even after removing the template, however, all implementations were still generated in the .h file. A .cpp file was also generated but contained only a using statement referencing what was in the .h file.

After creating new modeled classes, I found that the "normal" behavior is, in fact, what I expected: class definitions are stored in a .h file and implementation details are in a .cpp file. I also retried creating a template class and then removing the template; again the behavior was as expected. It seems that I must have done something strange to my original class that I haven't figured out how to undo.

Thanks to those who offered comments!

链接地址: http://www.djcxy.com/p/31808.html

上一篇: 合并特定工作项目的更改

下一篇: 单独的代码生成头和实现