For over 3 days I've been dealing with CORBA and C++ and my app interface written in IDL.
在过去的3天里,我一直在处理CORBA和c++以及在IDL中编写的应用程序界面。
My app interface looks like this:
我的app界面是这样的:
#ifndef __FORUM_INTERFACE_IDL__
#define __FORUM_INTERFACE_IDL__
#include "Forum.idl"
typedef sequence<Forum> Forums;
interface ForumInterface
{
Forums getForumList(in Forum f);
Forums getUsersForumList(in long UsersID);
void addNewTopic(in Forum f, in long UsersID, in string title);
};
#endif
I "compile" it to *.hh and *.cc files by : omniidl -bcxx ForumInterface.idl
我把它“编译”到*。hh和*。cc文件:omniidl -bcxx forterface.idl。
My Forum-object (also defined in IDL) looks like:
我的forum对象(也在IDL中定义)如下:
#ifndef __FORUM_IDL__
#define __FORUM_IDL__
interface Forum
{
long getForumID();
void setForumID(in long id);
string getForumName();
void setFroumName(in string name);
Forum getForumParent();
void setForumParent(in Forum f);
};
#endif
I "compile" it to *.hh and *.cc files by : omniidl -bcxx Forum.idl
我把它“编译”到*。hh和*。cc文件:omniidl -bcxx Forum.idl。
I tried to write an implementation of both Forum and ForumInterface. I started with Forum, here's definition of class FroumImpl:
我试着写了一个论坛和forterface的实现。我从论坛开始,这里定义了类FroumImpl:
#ifndef __FORUMIMPL_H__
#define __FORUMIMPL_H__
#include "Forum.hh"
class ForumImpl : public POA_Forum
{
private :
long id;
char *name;
ForumImpl parent;
public :
long getForumID();
void setForumID(long id);
char* getForumName();
void setFroumName(const char* name);
ForumImpl getForumParent();
void setForumParent(ForumImpl f);
};
#endif
and it's declaration (for now it's empty):
它的声明(现在是空的):
#include "ForumImpl.h"
long ForumImpl::getForumID(){}
void ForumImpl::setForumID(long id){}
char* ForumImpl::getForumName(){}
void ForumImpl::setFroumName(const char* name){}
ForumImpl ForumImpl::getForumParent(){}
void ForumImpl::setForumParent(ForumImpl f){}
I tried to compile it,
我尝试编译它,
g++ -c ForumImpl.cpp -I$OMNIORB_HOME/include -I$OMNIORB_HOME/include/omniORB4
but got errors:
但是有错误:
In file included from ForumImpl.cpp:1:0: ForumImpl.h:12:19: error: field ‘parent’ has incomplete type ForumImpl.h:20:19: error: conflicting return type specified for ‘virtual ForumImpl ForumImpl::getForumParent()’ Forum.hh:161:21: error: overriding ‘virtual _objref_Forum* _impl_Forum::getForumParent()’ ForumImpl.h:20:19: error: invalid abstract return type for member function ‘virtual ForumImpl ForumImpl::getForumParent()’ ForumImpl.h:6:7: note: because the following virtual functions are pure within ‘ForumImpl’: Forum.hh:162:16: note: virtual void _impl_Forum::setForumParent(Forum_ptr) ForumImpl.h:21:14: error: cannot declare parameter ‘f’ to be of abstract type ‘ForumImpl’ ForumImpl.h:6:7: note: since type ‘ForumImpl’ has pure virtual functions ForumImpl.cpp: In member function ‘virtual ForumImpl ForumImpl::getForumParent()’: ForumImpl.cpp:7:11: error: invalid abstract return type for member function ‘virtual ForumImpl ForumImpl::getForumParent()’ ForumImpl.h:6:7: note: since type ‘ForumImpl’ has pure virtual functions ForumImpl.cpp: At global scope: ForumImpl.cpp:8:42: error: cannot declare parameter ‘f’ to be of abstract type ‘ForumImpl’ ForumImpl.h:6:7: note: since type ‘ForumImpl’ has pure virtual functions
文件中包括了从ForumImpl。cpp:1:0:ForumImpl。h:12:19:错误:field ' parent '有不完整的类型ForumImpl。h:20:19:错误:为“虚拟ForumImpl ForumImpl::getForumParent()论坛”指定的冲突返回类型。@ hh:161:21:错误:覆盖“虚拟_objref_Forum* _request_forum::getForumParent()”ForumImpl。h:20:19:错误:为成员函数的虚拟ForumImpl ForumImpl::getForumParent()“ForumImpl”的抽象返回类型无效。h:6:7:注意:因为下面的虚拟函数在“ForumImpl”:论坛中是纯的。请注意:虚拟void _impl_Forum::setForumParent(Forum_ptr) ForumImpl。h:21:14:错误:不能声明参数f为抽象类型“ForumImpl”ForumImpl。h:6:7:注意:因为“ForumImpl”类型有纯虚拟功能。cpp:在成员函数的虚拟ForumImpl ForumImpl::getForumParent(): ForumImpl。cpp:7:11:错误:成员函数的虚拟ForumImpl ForumImpl::getForumParent()“ForumImpl”的抽象返回类型无效。h:6:7:注意:因为“ForumImpl”类型有纯虚拟功能。cpp:在全球范围:ForumImpl。cpp:8:42:错误:不能声明参数“f”为抽象类型“ForumImpl”ForumImpl。h:6:7:注意:“ForumImpl”类型有纯虚函数。
the worst thing is I have no idea why this code gives me such errors ... I mean, I defined all of ForumImpl
functions ... so any of them is virtual now. I spent hours and hours trying figure out what's wrong with this but have no clue :(
最糟糕的是,我不知道为什么这个代码会给我这样的错误……我的意思是,我定义了所有的ForumImpl函数…它们中的任何一个都是虚的。我花了好几个小时的时间试图弄明白这到底是怎么回事,但毫无头绪
Could anyone help? My files: http://www6.zippyshare.com/v/69552292/file.html I added to this tar archive a Makefile, so simply run command "make all" and this will do everything.
有人能帮忙吗?我的文件:http://www6.zippyshare.com/v/69552292/file.html我添加到这个tar存档文件中,所以简单地运行命令“make all”,这将完成所有事情。
I would be very grateful if anyone could tell my why I got those error and what to do to fix this, I really need it. Cheers:)
如果有人能告诉我为什么我犯了这些错误,我将非常感激,我真的需要它。欢呼:)
EDIT:
编辑:
I changed my ForumImpl.h and ForumImpl.cpp:
我改变了ForumImpl。h和ForumImpl.cpp:
#ifndef __FORUMIMPL_H__
#define __FORUMIMPL_H__
#include "Forum.hh"
class ForumImpl : public POA_Forum
{
private :
long id;
char *name;
ForumImpl *parent;
public :
long getForumID();
void setForumID(long id);
char* getForumName();
void setFroumName(const char* name);
ForumImpl* getForumParent();
void setForumParent(ForumImpl *f);
};
#endif
#include "ForumImpl.h"
long ForumImpl::getForumID(){}
void ForumImpl::setForumID(long id){}
char* ForumImpl::getForumName(){}
void ForumImpl::setFroumName(const char* name){}
ForumImpl* ForumImpl::getForumParent(){}
void ForumImpl::setForumParent(ForumImpl *f){}
but this gave me those erros:
但这给了我那些erros:
g++ -c ForumImpl.cpp -IMNIORB_HOME/include -IMNIORB_HOME/include/omniORB4 In file included from ForumImpl.cpp:1:0: ForumImpl.h:20:20: error: invalid covariant return type for ‘virtual ForumImpl* ForumImpl::getForumParent()’ Forum.hh:161:21: error: overriding ‘virtual _objref_Forum* _impl_Forum::getForumParent()’
g++ - c ForumImpl。cpp -IMNIORB_HOME/包括-IMNIORB_HOME/包括来自ForumImpl的文件中包含/omniORB4。cpp:1:0:ForumImpl。h:20:20:错误:虚拟ForumImpl* ForumImpl::getForumParent()论坛的协变返回类型无效。hh:161:21:错误:覆盖“虚拟_objref_Forum* _request_forum::getForumParent()”
2 个解决方案
#1
2
The signature for ForumImpl::getForumParent()
should look like this:
ForumImpl::getForumParent()的签名应该是这样的:
Forum_ptr getForumParent();
For more information you should download the IDL to C++ mapping document from the OMG website. Also check out Henning & Vinowski's book Advanced CORBA Programming with C++.
要获得更多信息,您应该从OMG网站下载IDL到c++映射文档。还可以看看Henning & Vinowski的书《高级CORBA编程与c++》。
#2
1
The method signatures in ForumImpl should match the base class as generated in Forum.hh. They should return just Forum. I don't know omniorb in detail, but TAO has hundreds of examples that use this, for example our bank example, you can also find that online at https://svn.dre.vanderbilt.edu/viewvc/Middleware/trunk/TAO/examples/Simple/bank/
ForumImpl中的方法签名应该与Forum.hh中生成的基类相匹配。他们应该只返回论坛。我不知道omniorb的细节,但是TAO有数百个例子,例如我们的银行示例,您也可以在https://svn.dre.vanderbilt.edu/viewvc/middleware//examples/simple/bank/上找到它。
#1
2
The signature for ForumImpl::getForumParent()
should look like this:
ForumImpl::getForumParent()的签名应该是这样的:
Forum_ptr getForumParent();
For more information you should download the IDL to C++ mapping document from the OMG website. Also check out Henning & Vinowski's book Advanced CORBA Programming with C++.
要获得更多信息,您应该从OMG网站下载IDL到c++映射文档。还可以看看Henning & Vinowski的书《高级CORBA编程与c++》。
#2
1
The method signatures in ForumImpl should match the base class as generated in Forum.hh. They should return just Forum. I don't know omniorb in detail, but TAO has hundreds of examples that use this, for example our bank example, you can also find that online at https://svn.dre.vanderbilt.edu/viewvc/Middleware/trunk/TAO/examples/Simple/bank/
ForumImpl中的方法签名应该与Forum.hh中生成的基类相匹配。他们应该只返回论坛。我不知道omniorb的细节,但是TAO有数百个例子,例如我们的银行示例,您也可以在https://svn.dre.vanderbilt.edu/viewvc/middleware//examples/simple/bank/上找到它。