ctkEASignalPublisher.cpp 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) German Cancer Research Center,
  4. Division of Medical and Biological Informatics
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================================*/
  15. #include "ctkEASignalPublisher_p.h"
  16. #include "ctkEventAdminService_p.h"
  17. ctkEASignalPublisher::ctkEASignalPublisher(ctkEventAdminService* eventAdmin,
  18. const QString& signal,
  19. const QString& topic)
  20. : eventAdmin(eventAdmin), signal(signal), topic(topic)
  21. {
  22. }
  23. QString ctkEASignalPublisher::getSignalName() const
  24. {
  25. return signal;
  26. }
  27. QString ctkEASignalPublisher::getTopicName() const
  28. {
  29. return topic;
  30. }
  31. void ctkEASignalPublisher::publishSyncSignal(const ctkDictionary& eventProps)
  32. {
  33. ctkDictionary props(eventProps);
  34. props.insert(ctkEventConstants::EVENT_TOPIC, topic);
  35. ctkEvent event(topic, props);
  36. eventAdmin->sendEvent(event);
  37. }
  38. void ctkEASignalPublisher::publishAsyncSignal(const ctkDictionary& eventProps)
  39. {
  40. ctkDictionary props(eventProps);
  41. props.insert(ctkEventConstants::EVENT_TOPIC, topic);
  42. ctkEvent event(topic, props);
  43. eventAdmin->postEvent(event);
  44. }