[omniORB] Weekend CORBA blues #1: CORBA::Any extractor/injector operators

Bruce Fountain B_Fountain@motherwell.com.au
Mon, 11 Jun 2001 07:56:51 +0800


My stub code seems to be missing the implementation of the >>= operator for
my user-defined datatypes. For example, the code below compiles just fine,
but gives me two link errors:

    Server.obj : error LNK2001: unresolved external symbol "void __cdecl
    operator<<=(class CORBA::Any &,struct Foo::fooStruct const &)"
    (??_3@YAXAAVAny@CORBA@@ABUfooStruct@Foo@@@Z)

    Server.obj : error LNK2001: unresolved external symbol "bool __cdecl
    operator>>=(class CORBA::Any const &,struct Foo::fooStruct * &)" 
    (??_2@YA_NABVAny@CORBA@@AAPAUfooStruct@Foo@@@Z)

Any suggestions? I have specified the -Wba option to get Any/Typecode
support. Is there something else I need? I am using omniORB 3.0.3 on NT4.

Best regards,

Bruce Fountain
Mi Consulting Group (Australia) Pty Ltd
Direct Line:  +61 (0)8 9368 8607
Switchboard:  +61 (0)8 9368 8600
Facsimile:    +61 (0)8 9368 8699
E-mail: b_fountain@motherwell.com.au

    // Foo.idl
    //
    // Compiled with the following command:
    //      omniidl -bcxx -Wba -Wbh=.h -Wbs=.cpp Foo.idl
    interface Foo
    {
        struct fooStruct
        {
            string record1;
            string record2;
        };

        void doFoo(in any data);
    };

    // Server.cpp
    //
    // Instantiate a single servant which implements the Foo interface
    #include <iostream>
    #include "Foo.h"

    class FooImpl : public virtual POA_Foo
    {
    public:
        virtual void doFoo(const CORBA::Any& data)
        {
            Foo::fooStruct* fs = NULL;
            if (data >>= fs)
            {
                std::cout << "... contains a fooStruct {" <<
fs->record1.in()
                << "," << fs->record2.in() << "}\n";

                m_lastData <<= *fs; // store a copy
            }
            else
            {
                std::cout << "... contains an unrecognised type\n";
            }
        }
    private:
        CORBA::Any m_lastData;
    };

    int main(int argc, char* argv[])
    {
        FooImpl foo;
        return 0;
    }