Discussion:
[omniORB] abstract class
Marek Cichy
2009-03-05 02:22:30 UTC
Permalink
Hi list
My problem: I have succesfully compiled my idl file, included .hh and
.cc files into project and defined interface functions. When I compile
the project I get an error " C2259: 'Simple_impl' : cannot instantiate
abstract class". I compared my project with few examples and everything
seems to be written properly. Below I listed .idl file and
implementations of interface functions. Can someone give me some help? I
try to create object in a following way:

Simple_impl* simple_servant = new Simple_impl();

My SW:
OS: WXP SP3
ORB: omniORB 4.1.2
IDE: VS2008

ITestServer.idl:
-------------------------------------------------------
#ifndef _ITEST_SERVER_
#define _ITEST_SERVER_

module ITestServer {
typedef char ct [1000];
typedef double dt [1000];

interface ISimple {
char _get_char(in unsigned short _index);
double _get_double(in unsigned short _index);
void _set_char(in char c,in unsigned short _index);
void _set_double(in double d,in unsigned short _index);
};
interface IComplex {
void _get_char_table(inout ct _char_table);
void _get_double_table(inout dt _double_table);
void _fill_char_table(in ct _char_table);
void _fill_double_table(in dt _double_table);
};
};
#endif // _ITEST_SERVER_
------------------------------------------------------
functions declarations:
------------------------------------------------------
#include "ITestServer.h"

class Simple_impl : public virtual POA_ITestServer::ISimple
{
private:
char tc[1000];
double td[1000];
public:
Simple_impl();
public:
virtual char _get_char(unsigned short _index)
throw(CORBA::SystemException);
virtual double _get_double(unsigned short _index)
throw(CORBA::SystemException);
virtual void _set_char(char c, unsigned short _index)
throw(CORBA::SystemException);
virtual void _set_double(double d, unsigned short _index)
throw(CORBA::SystemException);
};

class Complex_impl : public virtual POA_ITestServer::IComplex
{
private:
char tc[1000];
double td[1000];
public:
Complex_impl();
public:
virtual void _get_char_table(char _char_table[])
throw(CORBA::SystemException);
virtual void _get_double_table(double _double_table[])
throw(CORBA::SystemException);
virtual void _set_char_table(char _char_table[])
throw(CORBA::SystemException);
virtual void _set_double_table(double _double_table[])
throw(CORBA::SystemException);
};
-------------------------------------------------
functions definitions:
-------------------------------------------------
#include "server.h"

Simple_impl::Simple_impl()
{
for (int i=0;i<1000;i++)
this->tc[i]='s';
for (int i=0;i<1000;i++)
this->td[i]=3.14;
};
char Simple_impl::_get_char(unsigned short _index)
throw(CORBA::SystemException)
{
return this->tc[_index];
};
double Simple_impl::_get_double(unsigned short _index)
throw(CORBA::SystemException)
{
return this->td[_index];
};
void Simple_impl::_set_char(char c,unsigned short _index)
throw(CORBA::SystemException)
{
this->tc[_index]=c;
};
void Simple_impl::_set_double(double d,unsigned short _index)
throw(CORBA::SystemException)
{
this->td[_index]=d;
};
P.S.
At least could someone give any sign of life? I receive only answers for
other's questions.
Wernke Zur Borg (external)
2009-03-05 13:09:06 UTC
Permalink
-----Original Message-----
Of Marek Cichy
Sent: 04 March 2009 21:22
Subject: [omniORB] abstract class
Hi list
My problem: I have succesfully compiled my idl file, included .hh and
.cc files into project and defined interface functions. When
I compile
the project I get an error " C2259: 'Simple_impl' : cannot
instantiate
abstract class". I compared my project with few examples and
everything
seems to be written properly. Below I listed .idl file and
implementations of interface functions. Can someone give me
some help? I
Simple_impl* simple_servant = new Simple_impl();
OS: WXP SP3
ORB: omniORB 4.1.2
IDE: VS2008
-------------------------------------------------------
#ifndef _ITEST_SERVER_
#define _ITEST_SERVER_
module ITestServer {
typedef char ct [1000];
typedef double dt [1000];
interface ISimple {
char _get_char(in unsigned short _index);
double _get_double(in unsigned short _index);
void _set_char(in char c,in unsigned short _index);
void _set_double(in double d,in unsigned short _index);
};
interface IComplex {
void _get_char_table(inout ct _char_table);
void _get_double_table(inout dt _double_table);
void _fill_char_table(in ct _char_table);
void _fill_double_table(in dt _double_table);
};
};
#endif // _ITEST_SERVER_
------------------------------------------------------
------------------------------------------------------
#include "ITestServer.h"
class Simple_impl : public virtual POA_ITestServer::ISimple
{
char tc[1000];
double td[1000];
Simple_impl();
virtual char _get_char(unsigned short _index)
throw(CORBA::SystemException);
virtual double _get_double(unsigned short _index)
throw(CORBA::SystemException);
virtual void _set_char(char c, unsigned short _index)
throw(CORBA::SystemException);
virtual void _set_double(double d, unsigned short _index)
throw(CORBA::SystemException);
};
class Complex_impl : public virtual POA_ITestServer::IComplex
{
char tc[1000];
double td[1000];
Complex_impl();
virtual void _get_char_table(char _char_table[])
throw(CORBA::SystemException);
virtual void _get_double_table(double _double_table[])
throw(CORBA::SystemException);
virtual void _set_char_table(char _char_table[])
throw(CORBA::SystemException);
virtual void _set_double_table(double _double_table[])
throw(CORBA::SystemException);
};
-------------------------------------------------
-------------------------------------------------
#include "server.h"
Simple_impl::Simple_impl()
{
for (int i=0;i<1000;i++)
this->tc[i]='s';
for (int i=0;i<1000;i++)
this->td[i]=3.14;
};
char Simple_impl::_get_char(unsigned short _index)
throw(CORBA::SystemException)
{
return this->tc[_index];
};
double Simple_impl::_get_double(unsigned short _index)
throw(CORBA::SystemException)
{
return this->td[_index];
};
void Simple_impl::_set_char(char c,unsigned short _index)
throw(CORBA::SystemException)
{
this->tc[_index]=c;
};
void Simple_impl::_set_double(double d,unsigned short _index)
throw(CORBA::SystemException)
{
this->td[_index]=d;
};
P.S.
At least could someone give any sign of life? I receive only
answers for
other's questions.
Hi Marek,

I can't see any obvious mistake, but as a hint, use the -Wbexample
option of the IDL compiler to generate an example implementation file
ITestServer_i.cc with correct signatures, where you only need to insert
your function body code.

Regards, Wernke
Clarke Brunt
2009-03-05 15:24:18 UTC
Permalink
Post by Marek Cichy
My problem: I have succesfully compiled my idl file, included .hh and
.cc files into project and defined interface functions. When I compile
the project I get an error " C2259: 'Simple_impl' : cannot instantiate
abstract class"...
I've failed to spot anything obvious either. Obviously the error message
means that the compiler believes that you haven't implemented at least one
of the abstract methods in POA_ITestServer::ISimple. This would happen if
the 'signatures' of your methods didn't match. Why not try making the
datatypes of the arguments be the proper CORBA datatypes, e.g.
CORBA::UShort, CORBA::Double, CORBA::Char etc. Perhaps these aren't exactly
unsigned short, double, & char with your compiler. Could it be whether
'char' is signed or unsigned which is the problem? Find the source for
POA_ITestServer::ISimple in the generated headers, and look what exactly you
should be implementing.
Näwe, Stefan
2009-03-05 19:37:05 UTC
Permalink
-----Original Message-----
Of Marek Cichy
Sent: Wednesday, March 04, 2009 9:22 PM
Subject: [omniORB] abstract class
Hi list
My problem: I have succesfully compiled my idl file, included .hh and
.cc files into project and defined interface functions. When
I compile
the project I get an error " C2259: 'Simple_impl' : cannot
instantiate
abstract class". I compared my project with few examples and
everything
seems to be written properly. Below I listed .idl file and
implementations of interface functions. Can someone give me
some help? I
Simple_impl* simple_servant = new Simple_impl();
My omniidl gives me the following declarations for the _get/_set functions:

virtual ::CORBA::Char get_char(::CORBA::UShort index) = 0;
virtual ::CORBA::Double get_double(::CORBA::UShort index) = 0;
virtual void set_char(::CORBA::Char c, ::CORBA::UShort index) = 0;
virtual void set_double(::CORBA::Double d, ::CORBA::UShort index) = 0;


Look Ma, no underscores!

Stefan
Clarke Brunt
2009-03-05 20:07:22 UTC
Permalink
Post by Näwe, Stefan
virtual ::CORBA::Char get_char(::CORBA::UShort index) = 0;
virtual ::CORBA::Double get_double(::CORBA::UShort index) = 0;
virtual void set_char(::CORBA::Char c, ::CORBA::UShort index) = 0;
virtual void set_double(::CORBA::Double d, ::CORBA::UShort index) = 0;
Look Ma, no underscores!
Well spotted! Those underscores evidently escaped the eyes of both myself
and Wernke. The original poster solved the problem (either by getting
omniidl to generate the examples, or by examining the definitions in the
generated header), but didn't actually say it was that was wrong before.

Some compilers/linkers add underscores, don't they? I wonder if perhaps some
previous error messages included the '_', and caused confusion.
Näwe, Stefan
2009-03-05 20:58:17 UTC
Permalink
-----Original Message-----
Of Clarke Brunt
Sent: Thursday, March 05, 2009 3:07 PM
Subject: RE: [omniORB] abstract class
Post by Näwe, Stefan
My omniidl gives me the following declarations for the _get/_set
virtual ::CORBA::Char get_char(::CORBA::UShort index) = 0;
virtual ::CORBA::Double get_double(::CORBA::UShort index) = 0;
virtual void set_char(::CORBA::Char c, ::CORBA::UShort
index) = 0;
Post by Näwe, Stefan
virtual void set_double(::CORBA::Double d,
::CORBA::UShort index) = 0;
Post by Näwe, Stefan
Look Ma, no underscores!
Well spotted! Those underscores evidently escaped the eyes of
both myself
and Wernke. The original poster solved the problem (either by getting
omniidl to generate the examples, or by examining the
definitions in the
generated header), but didn't actually say it was that was
wrong before.
Some compilers/linkers add underscores, don't they? I wonder
if perhaps some
previous error messages included the '_', and caused confusion.
I just read the CORBA Spec (CORBA-3.0-04-03-12.pdf). It says in ?3.2.3.1:

<quote>
...
To minimize the amount of work, users may lexically ?escape? identifiers by
prepending an underscore (_) to an identifier. This is a purely lexical convention that
ONLY turns off keyword checking. The resulting identifier follows all the other rules
for identifier processing. For example, the identifier _AnIdentifier is treated as if it
were AnIdentifier.
The following is a non-exclusive list of implications of these rules:
? The underscore does not appear in the Interface Repository.
? The underscore is not used in the DII and DSI.
? The underscore is not transmitted over ?the wire.?
? Case sensitivity rules are applied to the identifier after stripping off the leading
underscore.
For example:
module M {
interface thing {
attribute boolean abstract; // error: abstract collides with
// keyword abstract
attribute boolean _abstract; // ok: abstract is an identifier
};
};
...
</quote>

Everything explained...

Stefan
Marek Cichy
2009-03-06 01:44:54 UTC
Permalink
Post by Näwe, Stefan
-----Original Message-----
Of Clarke Brunt
Sent: Thursday, March 05, 2009 3:07 PM
Subject: RE: [omniORB] abstract class
Post by Näwe, Stefan
My omniidl gives me the following declarations for the _get/_set
virtual ::CORBA::Char get_char(::CORBA::UShort index) = 0;
virtual ::CORBA::Double get_double(::CORBA::UShort index) = 0;
virtual void set_char(::CORBA::Char c, ::CORBA::UShort
index) = 0;
Post by Näwe, Stefan
virtual void set_double(::CORBA::Double d,
::CORBA::UShort index) = 0;
Post by Näwe, Stefan
Look Ma, no underscores!
Well spotted! Those underscores evidently escaped the eyes of
both myself
and Wernke. The original poster solved the problem (either by getting
omniidl to generate the examples, or by examining the
definitions in the
generated header), but didn't actually say it was that was
wrong before.
Some compilers/linkers add underscores, don't they? I wonder
if perhaps some
previous error messages included the '_', and caused confusion.
<quote>
...
To minimize the amount of work, users may lexically ?escape? identifiers by
prepending an underscore (_) to an identifier. This is a purely lexical convention that
ONLY turns off keyword checking. The resulting identifier follows all the other rules
for identifier processing. For example, the identifier _AnIdentifier is treated as if it
were AnIdentifier.
? The underscore does not appear in the Interface Repository.
? The underscore is not used in the DII and DSI.
? The underscore is not transmitted over ?the wire.?
? Case sensitivity rules are applied to the identifier after stripping off the leading
underscore.
module M {
interface thing {
attribute boolean abstract; // error: abstract collides with
// keyword abstract
attribute boolean _abstract; // ok: abstract is an identifier
};
};
...
</quote>
Everything explained...
Stefan
_______________________________________________
omniORB-list mailing list
http://www.omniorb-support.com/mailman/listinfo/omniorb-list
__________ NOD32 Informacje 3910 (20090305) __________
Wiadomosc zostala sprawdzona przez System Antywirusowy NOD32
http://www.nod32.com lub http://www.nod32.pl
Finally I do not know, if there were those underscores or wrong data
types, because I desperately ;-) tested _all_ ideas that came into mine
or compiler's (IntelliSense) mind. Anyway, I did not know about
specification mentioning this neither and next time I'll remember this.
Thanks again Stefan and Clarke.
Regards
Marek
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.omniorb-support.com/pipermail/omniorb-list/attachments/20090305/2c768789/attachment.htm
Martin Trappel
2009-03-06 13:43:57 UTC
Permalink
Post by Marek Cichy
Hi list
My problem: I have succesfully compiled my idl file, included .hh and
.cc files into project and defined interface functions. When I compile
the project I get an error " C2259: 'Simple_impl' : cannot instantiate
abstract class". I compared my project with few examples and everything
...
Since you appear to be using Visual Studio you should look at the error
output. It not only will tell you that it cannot instantiate the
abstract class, but also which function(s) are causing it. (Switch from
the error window to the output window)

br,
Martin

Loading...