|
From: Karel G. <kg...@us...> - 2002-03-23 20:17:16
|
Update of /cvsroot/micomt/mico/demo/ccm/hello2
In directory usw-pr-cvs1:/tmp/cvs-serv31844/demo/ccm/hello2
Added Files:
Makefile README client.cc hello hello.idl hello_impl.cc
Log Message:
- merged with MICO 2.3.7
--- NEW FILE: Makefile ---
all: all_target
DIR_PREFIX=../
include ../../MakeVars
INSTALL_DIR = ccm/hello2
INSTALL_SRCS = README Makefile client.cc hello.idl hello_impl.cc
INSTALL_SCRIPTS = hello
all_target: .depend client hello.$(SOEXT)
client: client.o hello.pic.o $(DEPS)
$(LD) $(CXXFLAGS) $(LDFLAGS) -o $@ client.o hello.pic.o -lmicoccm$(VERSION) -lmicocoss$(VERSION) $(LDLIBS)
hello.$(SOEXT): hello_impl.pic.o hello_ccm.pic.o hello.pic.o $(DEPS)
$(RM) $@
$(LDSO) $(CXXFLAGS) $(LDFLAGS) -o hello hello_impl.pic.o hello_ccm.pic.o hello.pic.o -lmicoccm$(VERSION) $(LDLIBS)
clean:
$(RM) client hello.$(SOEXT)
$(RM) hello_ccm.cc hello_ccm.h
$(RM) hello.cc hello.h
$(RM) *.o *.$(SOEXT) *~ core *.ior .depend
client.o: client.cc hello.h
hello.pic.o: hello.cc
hello_impl.pic.o: hello_impl.cc hello_ccm.h hello.h
hello_ccm.pic.o: hello_ccm.cc
hello_ccm.cc hello_ccm.h: hello.idl
$(CCMGEN) $^
hello.cc hello.h: hello.idl
$(IDL) $^
--- NEW FILE: README ---
This is the same example as ../hello, but compiles the component into
a loadable shared library.
--- NEW FILE: client.cc ---
#include <CORBA.h>
#include <mico/CosNaming.h>
#include "hello.h"
int
main (int argc, char *argv[])
{
CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
CORBA::Object_var obj = orb->resolve_initial_references ("NameService");
CosNaming::NamingContextExt_var nc =
CosNaming::NamingContextExt::_narrow (obj);
assert (!CORBA::is_nil (nc));
obj = nc->resolve_str ("HelloHome");
assert (!CORBA::is_nil (obj));
HelloHome_var hh = HelloHome::_narrow (obj);
HelloWorld_var hw = hh->create ();
hw->message ("Hello World");
hw->sayHello ();
hw->remove ();
return 0;
}
--- NEW FILE: hello ---
#!/bin/sh
MICORC=/dev/null
export MICORC
# run Naming Service
echo "Starting Naming Service ..."
rm -f nsd.ior
nsd --ior nsd.ior &
nsd_pid=$!
trap "kill $nsd_pid > /dev/null 2> /dev/null" 0
# wait for Naming Service to start
for i in 0 1 2 3 4 5 6 7 8 9 ; do
if test -r nsd.ior ; then break ; else sleep 1 ; fi
done
# start Server Activator
echo "Starting Server Activator ..."
rm -f ccmd.ior
mico-ccmd --ior ccmd.ior &
server_pid=$!
trap "kill $nsd_pid $server_pid > /dev/null 2> /dev/null" 0
# wait for Server Activator to start
for i in 0 1 2 3 4 5 6 7 8 9 ; do
if test -r ccmd.ior ; then break ; else sleep 1 ; fi
done
echo "Loading HelloWorld component ..."
ccmload -ORBInitRef NameService=file://`pwd`/nsd.ior --sa file://`pwd`/ccmd.ior --ns HelloHome -v HelloHome ./hello.so
# run Client
echo "Running Client ..."
./client -ORBInitRef NameService=file://`pwd`/nsd.ior
--- NEW FILE: hello.idl ---
interface Hello {
void sayHello ();
};
component HelloWorld supports Hello {
attribute string message;
};
home HelloHome manages HelloWorld {
};
--- NEW FILE: hello_impl.cc ---
#include "hello.h"
class HelloWorld_impl : virtual public CCM_HelloWorld {
private:
CORBA::String_var _msg;
public:
void sayHello ()
{
cout << _msg << endl;
}
char * message ()
{
return CORBA::string_dup (_msg);
}
void message (const char * msg)
{
_msg = CORBA::string_dup (msg);
}
};
class HelloHome_impl : virtual public CCM_HelloHome {
public:
Components::EnterpriseComponent_ptr create ()
{
return new HelloWorld_impl;
}
};
extern "C" {
Components::HomeExecutorBase_ptr create_HelloHome ()
{
return new HelloHome_impl;
}
}
|