Ticket #750 (closed defect: fixed)

Opened 10 years ago

Last modified 7 years ago

Unable to create transmitters in C++ with default EventSystem

Reported by: RayPlante Owned by: srp
Priority: normal Milestone:
Component: ctrl_events Keywords:
Cc: Blocked By:
Blocking: #740 Project: LSST
Version Number:
How to repeat:

not applicable

Description (last modified by RayPlante) (diff)

I cannot seem to register an event transmitter with the default EventSystem in C++ using code like this:

   EventSystem eventSystem = EventSystem::getDefaultEventSystem();
   eventSystem.createTransmitter(eventBrokerHost, "LSSTLogging");
   EventLog::createDefaultLog(runId, sliceId);

When I subsequently try to send a log message to the EventLog, I get the exception message:

   topic LSSTLogging is not registered with EventSystem

This is apparently due to the fact that in the code above, I am registering with a copy of the default EventSystem (which is created automatically as part of the assignment to eventSystem). As part of that copy, copies are made of the internal lists of transmitters. When I create a new transmitter, this copy gets added to my copy of the EventSystem; however, the new transmitter is not seen by the actual instance of the default EventSystem.

To solve this problem, I need to be able to say the following:

   EventSystem& eventSystem = EventSystem.getDefaultEventSystem()

Now I have a reference to the default EventSystem; any new transmitters I create will be registered with the actual default EventSystem. Unfortunately, I cannot do this because getDefaultEventSystem() returns a const EventSystem&.

The solution to this is to remove the const from the return type from getDefaultEventSystem().

Note that I made the exact same error with getDefaultLog() upon which this usage was based. I'll also note that the equivalent to the above code in Python works, though I don't know why. I suspect that the const gets thrown away in the swigging.

Change History

comment:1 Changed 10 years ago by RayPlante

  • Description modified (diff)

comment:2 Changed 10 years ago by ktl

Another option could be to return a boost::shared_ptr.

For the Python/SWIG explanation, see the SWIG manual.

comment:3 Changed 10 years ago by srp

  • Status changed from new to closed
  • Resolution set to fixed

Fix committed. r9090:9091.

comment:4 Changed 7 years ago by robyn

  • Milestone DC3a MW Interface deleted

Milestone DC3a MW Interface deleted

Note: See TracTickets for help on using tickets.