void FissionReactor::updateCodecs(void) { // check if the codec was deleted (if so, stop now!) if (! getCodecFactory().hasPlugin(m_codec_id)) { stop(); boost::mutex::scoped_lock codec_lock(m_codec_mutex); m_codec_ptr.reset(); } else { // update the codec pointer boost::mutex::scoped_lock codec_lock(m_codec_mutex); m_codec_ptr = getCodecFactory().getCodec(m_codec_id); } }
/////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Retrieve a codec that can handle the specified // transfer syntax // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// ptr<codec> codecFactory::getCodec(std::wstring transferSyntax) { PUNTOEXE_FUNCTION_START(L"codecFactory::getCodec"); ptr<codecFactory> pFactory(getCodecFactory()); lockObject lockAccess(pFactory.get()); for(std::list<ptr<codec> >::iterator scanCodecs=pFactory->m_codecsList.begin(); scanCodecs!=pFactory->m_codecsList.end(); ++scanCodecs) { if((*scanCodecs)->canHandleTransferSyntax(transferSyntax)) { return (*scanCodecs)->createCodec(); } } ptr<codec> emptyCodec; return emptyCodec; PUNTOEXE_FUNCTION_END(); }
/////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// // // // Load the data from the specified stream and build a // dicomSet structure // // /////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////// ptr<dataSet> codecFactory::load(ptr<streamReader> pStream, std::uint32_t maxSizeBufferLoad /* = 0xffffffff */) { PUNTOEXE_FUNCTION_START(L"codecFactory::load"); // Copy the list of codecs in a local list so we don't have // to lock the object for a long time /////////////////////////////////////////////////////////// std::list<ptr<codec> > localCodecsList; ptr<codecFactory> pFactory(getCodecFactory()); { lockObject lockAccess(pFactory.get()); for(std::list<ptr<codec> >::iterator scanCodecs=pFactory->m_codecsList.begin(); scanCodecs!=pFactory->m_codecsList.end(); ++scanCodecs) { ptr<codec> copyCodec((*scanCodecs)->createCodec()); localCodecsList.push_back(copyCodec); } } ptr<dataSet> pDataSet; for(std::list<ptr<codec> >::iterator scanCodecs=localCodecsList.begin(); scanCodecs != localCodecsList.end() && pDataSet == 0; ++scanCodecs) { try { return (*scanCodecs)->read(pStream, maxSizeBufferLoad); } catch(codecExceptionWrongFormat& /* e */) { exceptionsManager::getMessage(); // Reset the messages stack continue; } } if(pDataSet == 0) { PUNTOEXE_THROW(codecExceptionWrongFormat, "none of the codecs recognized the file format"); } return pDataSet; PUNTOEXE_FUNCTION_END(); }
void FissionReactor::setConfig(const Vocabulary& v, const xmlNodePtr config_ptr) { // first set config options for the Reactor base class ConfigWriteLock cfg_lock(*this); Reactor::setConfig(v, config_ptr); // get the input event type std::string config_str; if (! ConfigManager::getConfigOption(INPUT_EVENT_TYPE_ELEMENT_NAME, config_str, config_ptr)) throw EmptyInputEventTypeException(getId()); // find vocabulary term for input event type Vocabulary::TermRef term_ref = v.findTerm(config_str); if (term_ref == Vocabulary::UNDEFINED_TERM_REF) throw UnknownTermException(config_str); m_input_event_type = v[term_ref]; // make sure that term is object/event type if (m_input_event_type.term_type != Vocabulary::TYPE_OBJECT) throw NotAnObjectException(config_str); // get the input event term if (! ConfigManager::getConfigOption(INPUT_EVENT_TERM_ELEMENT_NAME, config_str, config_ptr)) throw EmptyInputEventTermException(getId()); // find vocabulary term for input event term term_ref = v.findTerm(config_str); if (term_ref == Vocabulary::UNDEFINED_TERM_REF) throw UnknownTermException(config_str); m_input_event_term = v[term_ref]; // only string types are currently supported for input event term switch (m_input_event_term.term_type) { case Vocabulary::TYPE_NULL: case Vocabulary::TYPE_OBJECT: case Vocabulary::TYPE_INT8: case Vocabulary::TYPE_INT16: case Vocabulary::TYPE_INT32: case Vocabulary::TYPE_UINT8: case Vocabulary::TYPE_UINT16: case Vocabulary::TYPE_UINT32: case Vocabulary::TYPE_INT64: case Vocabulary::TYPE_UINT64: case Vocabulary::TYPE_FLOAT: case Vocabulary::TYPE_DOUBLE: case Vocabulary::TYPE_LONG_DOUBLE: case Vocabulary::TYPE_DATE_TIME: case Vocabulary::TYPE_DATE: case Vocabulary::TYPE_TIME: throw TermNotStringException(config_str); break; case Vocabulary::TYPE_SHORT_STRING: case Vocabulary::TYPE_STRING: case Vocabulary::TYPE_LONG_STRING: case Vocabulary::TYPE_CHAR: case Vocabulary::TYPE_BLOB: case Vocabulary::TYPE_ZBLOB: break; // these are all OK } // get the codec to use boost::mutex::scoped_lock codec_lock(m_codec_mutex); if (! ConfigManager::getConfigOption(CODEC_ELEMENT_NAME, m_codec_id, config_ptr)) throw EmptyCodecException(getId()); m_codec_ptr = getCodecFactory().getCodec(m_codec_id); PION_ASSERT(m_codec_ptr); codec_lock.unlock(); // check if we should copy all terms from original event m_copy_all_terms = false; std::string copy_all_terms_str; if (ConfigManager::getConfigOption(COPY_ALL_TERMS_ELEMENT_NAME, copy_all_terms_str, config_ptr)) { if (copy_all_terms_str == "true") m_copy_all_terms = true; } // get list of terms to copy from original event m_copy_terms.clear(); xmlNodePtr copy_term_node = config_ptr; while ((copy_term_node = ConfigManager::findConfigNodeByName(COPY_TERM_ELEMENT_NAME, copy_term_node)) != NULL) { xmlChar *xml_char_ptr = xmlNodeGetContent(copy_term_node); if (xml_char_ptr != NULL) { const std::string copy_term_str(reinterpret_cast<char*>(xml_char_ptr)); xmlFree(xml_char_ptr); if (! copy_term_str.empty()) { // find the term in the Vocabulary term_ref = v.findTerm(copy_term_str); if (term_ref == Vocabulary::UNDEFINED_TERM_REF) throw UnknownTermException(copy_term_str); // add it to the copy terms collection m_copy_terms.push_back(v[term_ref]); } } // step to the next copy term copy_term_node = copy_term_node->next; } }