コード例 #1
0
ファイル: Description.cpp プロジェクト: uboot/stromx
 void Description::setVisualization(const VariantHandle & visualization)
 {
     if (! visualization.isValid())
         throw WrongArgument("Visualization of a description must be a valid variant.");
     
     m_visualization = visualization;
 }
コード例 #2
0
 MatrixParameter::MatrixParameter(const unsigned int id, const VariantHandle& variant, ParameterGroup* const group)
   : Parameter(id, variant, group),
     m_rows(0),
     m_cols(0)
 {
     if(! variant.isVariant(Variant::MATRIX))
         throw WrongArgument("The variant of a matrix parameter must be a matrix variant.");
 }
コード例 #3
0
ファイル: ImageWrapper.cpp プロジェクト: joccccc/stromx
 void ImageWrapper::validate(const unsigned int width,
                             const unsigned int height,
                             const unsigned int stride,
                             const uint8_t*const data,
                             const runtime::Image::PixelType pixelType) const
 {
     if(width == 0 || height == 0)
         return;
     
     // check row length
     if(width * depth(pixelType) * numChannels(pixelType) > stride)
         throw WrongArgument("Too small stride.");
     
     // check total data size
     unsigned int dataSize = stride * (height - 1) + width;
     if(data + dataSize > m_buffer + m_bufferSize)
         throw WrongArgument("Too small buffer.");
 }
コード例 #4
0
ファイル: DataContainerImpl.cpp プロジェクト: joccccc/stromx
 DataContainerImpl::DataContainerImpl(Data* data)
 : m_readAccessCounter(0),
     m_writeAccess(false),
     m_recycleAccess(0),
     m_data(data)
 {
     if(! data)
         throw WrongArgument();
 }
コード例 #5
0
ファイル: OperatorKernel.cpp プロジェクト: uboot/stromx
 void OperatorKernel::setConnectorType(const unsigned int id, const Description::Type type,
     const Parameter::UpdateBehavior updateBehavior)
 {
     const Description* description = findDescription(id);
     
     if (description->originalType() == Description::PARAMETER)
         throw WrongArgument("Can not set the connector type of parameters which are not originally connectors.");
     
     switch (type)
     {
     case Description::INPUT:
         if (description->originalType() != Description::INPUT)
             throw WrongArgument("Descriptions can only be turned into inputs if their original type is INPUT.");
         break;
     case Description::OUTPUT:
         if (description->originalType() != Description::OUTPUT)
             throw WrongArgument("Descriptions can only be turned into outputs if their original type is OUTPUT.");
         break;
     case Description::PARAMETER:
         if (description->originalType() == Description::INPUT &&
             updateBehavior == Description::PULL)
         {
             throw WrongArgument("Inputs can not be turned into pull parameters.");
         }
         if (description->originalType() == Description::OUTPUT &&
             updateBehavior == Description::PUSH)
         {
             throw WrongArgument("Outputs can not be turned into push parameters.");
         }
         break;
     default:
         break;
     }
     
     m_typeMap[id] = type;
     m_behaviorMap[id] = updateBehavior;
     
     updateVisibleDescriptions(true);
 }
コード例 #6
0
ファイル: Factory.cpp プロジェクト: roteroktober/stromx
 void Factory::registerData(const Data* data)
 {
     boost::lock_guard<boost::mutex> lock(m_mutex->mutex());
     
     if(data == 0)
     {
         throw WrongArgument("Invalid argument: Null pointer.");
     }
     
     for(std::vector<const Data*>::iterator iter = m_dataTypes.begin();
         iter != m_dataTypes.end();
         ++iter)
     {
         if(data->type() == (*iter)->type() && data->package() == (*iter)->package())
         {
             throw WrongArgument("Invalid argument: Data (" 
                 + data->package() + ", " + data->type() 
                 + ") has already been registered.");
         }
     }
     
     m_dataTypes.push_back(data);
 }
コード例 #7
0
ファイル: Factory.cpp プロジェクト: roteroktober/stromx
 void Factory::registerOperator(const OperatorKernel*const op)
 {
     boost::lock_guard<boost::mutex> lock(m_mutex->mutex());
     
     if(op == 0)
     {
         throw WrongArgument("Invalid argument: Null pointer.");
     }
     
     for(std::vector<const OperatorKernel*>::iterator iter = m_operators.begin();
         iter != m_operators.end();
         ++iter)
     {
         if(op->type() == (*iter)->type() && op->package() == (*iter)->package())
         {
             throw WrongArgument("Invalid argument: Operator (" 
                 + op->package() + ", " + op->type() 
                 + ") has already been registered.");
         }
     }
     
     m_operators.push_back(op);
 }
コード例 #8
0
ファイル: OperatorKernel.cpp プロジェクト: uboot/stromx
 const Description* OperatorKernel::findDescription(const unsigned int id) const
 {
     std::map<unsigned int, const Input*>::const_iterator inputIter = m_inputMap.find(id);
     if (inputIter != m_inputMap.end())
         return inputIter->second;
         
     std::map<unsigned int, const Output*>::const_iterator outputIter = m_outputMap.find(id);
     if (outputIter != m_outputMap.end())
         return outputIter->second;
         
     std::map<unsigned int, const Parameter*>::const_iterator parameterIter = m_parameterMap.find(id);
     if (parameterIter != m_parameterMap.end())
         return parameterIter->second;
         
     throw WrongArgument("No description for ID exists for this operator.");
 }
コード例 #9
0
ファイル: DataContainerImpl.cpp プロジェクト: joccccc/stromx
 void DataContainerImpl::getRecycleAccess(Recycler*const recycler)
 {        
     if(! recycler)
         throw WrongArgument();
     
     unique_lock_t lock(m_mutex);
     
     try
     {
         while(m_recycleAccess)
             m_cond.wait(lock);
     }
     catch(boost::thread_interrupted&)
     {
         throw Interrupt();
     } 
         
     m_recycleAccess = recycler;
 }
コード例 #10
0
ファイル: OperatorKernel.cpp プロジェクト: uboot/stromx
 void OperatorKernel::validateDescriptions(const std::vector<const Input*>& inputs,
                                           const std::vector<const Output*>& outputs,
                                           const std::vector<const Parameter*>& parameters)
 {
     std::set<unsigned int> existingIds;
     std::set<unsigned int> newIds;
     std::set<const Parameter*> allParameters;
     
     // collect all existing IDs
     for(std::vector<const Input*>::const_iterator iter = m_inputs.begin();
         iter != m_inputs.end();
         ++iter)
     {
         existingIds.insert((*iter)->id());
     }
     
     for(std::vector<const Output*>::const_iterator iter = m_outputs.begin();
         iter != m_outputs.end();
         ++iter)
     {
         existingIds.insert((*iter)->id());
     }
     
     for(std::vector<const Parameter*>::const_iterator iter = m_parameters.begin();
         iter != m_parameters.end();
         ++iter)
     {
         existingIds.insert((*iter)->id());
         allParameters.insert(*iter);
     }
     
     // collect all new IDs
     for(std::vector<const Input*>::const_iterator iter = inputs.begin();
         iter != inputs.end();
         ++iter)
     {
         if(newIds.count((*iter)->id()))
             throw WrongArgument("ID " + boost::lexical_cast<std::string>((*iter)->id()) + " appears twice.");
             
         newIds.insert((*iter)->id());
     }
     
     for(std::vector<const Output*>::const_iterator iter = outputs.begin();
         iter != outputs.end();
         ++iter)
     {
         if(newIds.count((*iter)->id()))
             throw WrongArgument("ID " + boost::lexical_cast<std::string>((*iter)->id()) + " appears twice.");
             
         newIds.insert((*iter)->id());
     }
     
     for(std::vector<const Parameter*>::const_iterator iter = parameters.begin();
         iter != parameters.end();
         ++iter)
     {
         if(newIds.count((*iter)->id()))
             throw WrongArgument("ID " + boost::lexical_cast<std::string>((*iter)->id()) + " appears twice.");
             
         newIds.insert((*iter)->id());
         allParameters.insert(*iter);
     }
     
     // check if any of the new IDs matches an existing ID
     for(std::set<unsigned int>::const_iterator iter = newIds.begin();
         iter != newIds.end();
         ++iter)
     {
         if(existingIds.count(*iter))
             throw WrongArgument("Descriptor with ID " + boost::lexical_cast<std::string>(*iter) + " has already been added.");
     }
     
     // check if all groups of the new parameters are part of this operator
     for(std::vector<const Parameter*>::const_iterator iter = parameters.begin();
         iter != parameters.end();
         ++iter)
     {
         if((*iter)->group())
         {
             if(! allParameters.count((*iter)->group()))
                 throw WrongArgument("Parameter with ID "
                     + boost::lexical_cast<std::string>(*iter)
                     + " references a group which has not been added to the operator.");
         }
     }
 }