Re: 'Instance' Data for Server-Side Objects
- From: Sam Couter <sam topic com au>
- To: orbit-list gnome org
- Subject: Re: 'Instance' Data for Server-Side Objects
- Date: Fri, 7 Dec 2001 12:18:33 +1100
Adam Buckley <adambuckley@gmx.net> wrote:
> Hi Gurus,
>
> How do I set 'instance' data for server-side object instances?
Use the servant struct by adding extra members to it. Look in the top of
the generated implementation skeleton for the struct
impl_POA_<Module>_<Interface> (where Module and Interface are as defined
in your IDL). Add members to it, and you can then use them in your code
(in the server only!).
> Ie, in server.c, I'd like to do something like this:
>
> // Normal creation from echo-skelimpl.c
> Echo echoServerObj1 = impl_Echo__create(poa, &env);
> Echo echoServerObj2 = impl_Echo__create(poa, &env);
>
> // Can I do this?
> echoServerObj1->something->specialNumber = 1;
> echoServerObj2->something->specialNumber = 2;
Not quite. You probably need to do something like:
servant = (MyServantType)
PortableServer_POA_reference_to_servant(poa, echoServerObj1, &env);
servant->specialNumber = 1;
> And in the implementation, I'd like to do something like this:
>
> static void impl_Echo_echoString(impl_POA_Echo *servant,
> CORBA_char *msg, CORBA_Environment *env)
> {
> // Can I do this?
> int servantNumber = servant->something->specialNumber;
>
> printf("servant %d says: %s\n", servantNumber, msg);
> return;
> }
You control the type for impl_POA_Echo (or whatever your object is
called in your IDL), so you can define whatever fields on it you like.
> Could anyone demonstrate how to do it? Or point me to some documentation?
> This is one time when object-orientated programming would come in handy...
You just need to know what methods to use and which objects to use them
on. ;)
--
Sam Couter | Internet Engineer | http://www.topic.com.au/
sam@topic.com.au | tSA Consulting |
OpenPGP key ID: DE89C75C, available on key servers
OpenPGP fingerprint: A46B 9BB5 3148 7BEA 1F05 5BD5 8530 03AE DE89 C75C
PGP signature
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]