00001 // Copyright CERN 2012 - Developed in collaboration with GSI 00002 #include <fesa-core/Core/OnDemandProducerImpl.h> 00003 #include <fesa-core/Core/AbstractMsgQueue.h> 00004 #include <fesa-core/Core/MessageTypes.h> 00005 00006 #include <cmw-log/Logger.h> 00007 00008 namespace 00009 { 00010 00011 CMW::Log::Logger& logger = CMW::Log::LoggerFactory::getLogger("FESA.FWK.fesa-core.Core"); 00012 00013 } 00014 00015 namespace fesa 00016 { 00017 00018 OnDemandProducerImpl::OnDemandProducerImpl(AbstractMsgQueue* msgQueue): msgQueue_(msgQueue) 00019 { 00020 00021 } 00022 00023 OnDemandProducerImpl::~OnDemandProducerImpl() 00024 { 00025 00026 } 00027 00028 void OnDemandProducerImpl::sendMessage(OnDemandMessage& message) 00029 { 00030 msgQueue_->checkState(message.prio_); 00031 if (AbstractEquipment::getInstance()->getProcessType() == unsplit) 00032 { 00033 //This is still very ugly 00034 //TODO check if shared pointers can be used here .. than we as well could get rid of the if/else 00035 AbstractMessage* msg = new OnDemandMessage(message); 00036 msgQueue_->postMsg(msg); 00037 } 00038 else 00039 { 00040 msgQueue_->postMsg(&message); 00041 } 00042 std::ostringstream stream; 00043 stream << "Posted On-Demand-Message on On-Demand message-queue: " << msgQueue_->getQueueName(); 00044 LOG_INFO_IF(logger, stream.str()); 00045 } 00046 00047 }