Example #1
0
/*******************  FUNCTION  *********************/
void ProjectActionOld::genItLoopCCode ( ostream& out, const CMRProjectContext& context, int depth ) const
{
	CMRProjectContext localContext(&context);

	//errors
	assert(name == "cmrSubBlock" && description == "cmrIteratorLoop");
	
	//search the related iterator definition
	const CMRProjectEntity * entity = context.parent->find(eq->latexEntity);
	if (entity == NULL)
	{
		cerr << "Can't find the definition of iterator " << eq->compute << " in current context." << endl;
		abort();
	}

	const CMRProjectIterator * iterator = dynamic_cast<const CMRProjectIterator*>(entity);
	if (iterator == NULL)
	{
		cerr << "Cuation, expect iterator " << eq->compute << " but get another type." << endl;
		context.printDebug();
		abort();
	}
	assert(iterator != NULL);
	
	CMRProjectLocalVariable localVar(eq->compute,eq->compute);
	localContext.addEntry(&localVar);
	out << genCCodeIndent(depth) << "for (int " << eq->compute << " = " << iterator->start << " ; " << eq->compute << " < " << iterator->end << " ; " << eq->compute << "++ )" <<endl;
	out << genCCodeIndent(depth) << "{" << endl;
	for (ConstIterator it = getFirstChild() ; ! it.isEnd() ; ++it)
		it->genCCode(out,it->context,depth+1);
		//it->genCCode(out,localContext,depth+1);
	out << genCCodeIndent(depth) << "}" << endl;
	
	//checkContext(localContext);
}
Example #2
0
bool KEntryMap::revertEntry(const QByteArray& group, const QByteArray& key, KEntryMap::SearchFlags flags)
{
    Q_ASSERT((flags & KEntryMap::SearchDefaults) == 0);
    Iterator entry = findEntry(group, key, flags);
    if (entry != end()) {
        //qDebug() << "reverting" << entry.key() << " = " << entry->mValue;
        if (entry->bReverted) { // already done before
            return false;
        }

        KEntryKey defaultKey(entry.key());
        defaultKey.bDefault = true;
        //qDebug() << "looking up default entry with key=" << defaultKey;
        const ConstIterator defaultEntry = constFind(defaultKey);
        if (defaultEntry != constEnd()) {
            Q_ASSERT(defaultEntry.key().bDefault);
            //qDebug() << "found, update entry";
            *entry = *defaultEntry; // copy default value, for subsequent lookups
        } else {
            entry->mValue = QByteArray();
        }
        entry->bDirty = true;
        entry->bReverted = true; // skip it when writing out to disk

        //qDebug() << "Here's what we have now:" << *this;
        return true;
    }
    return false;
}
Example #3
0
float get_mean(Image::Pointer im)
{
	ConstIterator it;
	it = ConstIterator(im, im->GetLargestPossibleRegion());
	
	float mean = 0, N=0;

	try
	{
		while(!it.IsAtEnd())
		{
			if(it.Get()!=0)
			{
				mean = N/(N+1)*mean + it.Get()/(N+1);
				++N;
			}
			++it;
		}
	}
	catch( itk::ExceptionObject & err)
	{
		std::cout<<"Error calculating mean, iterator error"<<std::endl;
		std::cout<<err<<std::endl;
	}

	return mean;
}
Example #4
0
/*******************  FUNCTION  *********************/
void ProjectActionOld::genRootElemCCode ( ostream& out, const CMRProjectContext& context, int depth ) const
{
	CMRProjectContext localContext(&context);
	for (ConstIterator it = getFirstChild() ; ! it.isEnd() ; ++it)
		it->genCCode(out,it->context,depth+1);
		//it->genCCode(out,localContext,depth+1);
	//checkContext(localContext);
}
Example #5
0
inline typename ListType::ConstIterator largestFragment(const ListType& src)
{
    typedef typename ListType::ConstIterator ConstIterator;
    ConstIterator result = src.begin();
    for( ConstIterator i = result; i != src.end(); ++i )
        if( result->length() < i->length() ) result = i;
    return result;
}
BreakpointId BreakHandler::findBreakpointByAddress(quint64 address) const
{
    ConstIterator it = m_storage.constBegin(), et = m_storage.constEnd();
    for ( ; it != et; ++it)
        if (it->data.address == address || it->response.address == address)
            return it.key();
    return BreakpointId();
}
BreakpointId BreakHandler::findBreakpointByFunction(const QString &functionName) const
{
    ConstIterator it = m_storage.constBegin(), et = m_storage.constEnd();
    for ( ; it != et; ++it)
        if (it->data.functionName == functionName)
            return it.key();
    return BreakpointId();
}
BreakpointId BreakHandler::findBreakpointByFileAndLine(const QString &fileName,
    int lineNumber, bool useMarkerPosition)
{
    ConstIterator it = m_storage.constBegin(), et = m_storage.constEnd();
    for ( ; it != et; ++it)
        if (it->isLocatedAt(fileName, lineNumber, useMarkerPosition))
            return it.key();
    return BreakpointId();
}
Example #9
0
 AnnotationStatistics FeatureMap::getAnnotationStatistics() const
 {
   AnnotationStatistics result;
   for (ConstIterator iter = this->begin(); iter != this->end(); ++iter)
   {
     result += iter->getAnnotationState();
   }
   return result;
 }
Int64
Header::writeTo (OStream &os, bool isTiled) const
{
    //
    // Write a "magic number" to identify the file as an image file.
    // Write the current file format version number.
    //

    Xdr::write <StreamIO> (os, MAGIC);

    int version = isTiled ? makeTiled (EXR_VERSION) : EXR_VERSION;
    Xdr::write <StreamIO> (os, version);

    //
    // Write all attributes.  If we have a preview image attribute,
    // keep track of its position in the file.
    //

    Int64 previewPosition = 0;

    const Attribute *preview =
        findTypedAttribute <PreviewImageAttribute> ("preview");

    for (ConstIterator i = begin(); i != end(); ++i)
    {
        //
        // Write the attribute's name and type.
        //

        Xdr::write <StreamIO> (os, i.name());
        Xdr::write <StreamIO> (os, i.attribute().typeName());

        //
        // Write the size of the attribute value,
        // and the value itself.
        //

        StdOSStream oss;
        i.attribute().writeValueTo (oss, version);

        std::string s = oss.str();
        Xdr::write <StreamIO> (os, (int) s.length());

        if (&i.attribute() == preview)
            previewPosition = os.tellp();

        os.write (s.data(), s.length());
    }

    //
    // Write zero-length attribute name to mark the end of the header.
    //

    Xdr::write <StreamIO> (os, "");

    return previewPosition;
}
Example #11
0
const char* MessageHeader::get(const char* key) const
{
    for (ConstIterator it = begin(); it != end(); ++it)
    {
        if (compareIgnoreCase(key, it->name()) == 0)
            return it->value();
    }

    return 0;
}
Example #12
0
void MessageHeader::remove(const char* key)
{
    if( ! *key)
        throw std::invalid_argument("header key is NULL");

    char* p = eptr();

    ConstIterator it = begin();
    while (it != end())
    {
        if (compareIgnoreCase(key, it->name()) == 0)
        {
            std::size_t slen = it->value() - it->name() + std::strlen(it->value()) + 1;

            std::memcpy(
                const_cast<char*>(it->name()),
                it->name() + slen,
                p - it->name() + slen);

            p -= slen;

            it.fixup();
        }
        else
            ++it;
    }

    _endOffset = p - _rawdata;
}
Example #13
0
QString TemplateDocument::finalText() const
{
    QString ready = d->templateText;
    typedef QMap<QString, QString>::ConstIterator ConstIterator;
    ConstIterator end = d->templateEntries.constEnd();
    for (ConstIterator i = d->templateEntries.constBegin(); i != end; i++) {
        ready.replace(QLatin1Char('%') + i.key() + QLatin1Char('%'), i.value());
    }
    d->processTemplateIncludes(ready);
    return ready;
}
BreakpointId BreakHandler::findWatchpoint(const BreakpointParameters &data) const
{
    ConstIterator it = m_storage.constBegin(), et = m_storage.constEnd();
    for ( ; it != et; ++it)
        if (it->data.isWatchpoint()
                && it->data.address == data.address
                && it->data.size == data.size
                && it->data.bitpos == data.bitpos)
            return it.key();
    return BreakpointId();
}
typename ListType::FragmentType
selectBlock(const ListType& src, typename ListType::FSizeType blockSize,
    const AvailableType* available )
{
    typedef typename ListType::FragmentType FragmentType;
    typedef typename ListType::FSizeType FSizeType;
    typedef typename ListType::ConstIterator ConstIterator;
    
    if( src.empty() ) return FragmentType( 0,
        ::std::numeric_limits< FSizeType >::max() );

    ::std::deque< FSizeType > blocks;

    for( ConstIterator selectIterator = src.begin();
        selectIterator != src.end(); ++selectIterator )
    {
        FSizeType blockBegin = selectIterator->begin() / blockSize;
        FSizeType blockEnd = ( selectIterator->end() - 1 ) / blockSize;
		if ( selectIterator->begin() % blockSize )
		{
			// the start of a block is complete, but part is missing
			
			if ( !available || available[ blockBegin ] )
			{
                return FragmentType( selectIterator->begin(),
                    ::std::min( selectIterator->end(),
                    blockSize * ( blockBegin + 1 ) ) );
			}
            ++blockBegin;
		}
		if ( blockBegin <= blockEnd && selectIterator->end() % blockSize
            && selectIterator->end() < src.limit() )
		{
			// the end of a block is complete, but part is missing
			
			if ( !available || available[ blockEnd ] )
			{
                return FragmentType( blockEnd * blockSize,
                    selectIterator->end() );
			}
            --blockEnd;
		}
		// this fragment contains one or more aligned empty blocks
        if( blockEnd != ~0ULL ) for( ; blockBegin <= blockEnd; ++blockBegin )
        {
            if( !available || available[ blockBegin ] )
            {
                blocks.push_back( blockBegin );
            }
        }
	}
	
    if( blocks.empty() )  return FragmentType( 0,
        ::std::numeric_limits< FSizeType >::max() );

    FSizeType blockBegin = blocks[ ::std::rand() % blocks.size() ] * blockSize;

    return FragmentType( blockBegin, ::std::min( blockBegin + blockSize, src.limit() ) );
}
Example #16
0
bool SVGTransformList::concatenate(AffineTransform& result) const
{
    if (isEmpty())
        return false;

    ConstIterator it = begin();
    ConstIterator itEnd = end();
    for (; it != itEnd; ++it)
        result *= it->matrix();

    return true;
}
void QFragmentMap::check()
{
    Q_ASSERT((head->node_count == 0 && head->root == 0)
             || (head->node_count != 0 && head->root != 0 && F(head->root).parent == 0));

    ConstIterator it = begin();
    int key = 0;
    for (; it != end(); ++it) {
        Q_ASSERT(key == it.key());
        key += (*it)->size;
    }
}
Example #18
0
VBHostedAllocator::~VBHostedAllocator()
{
    ConstIterator<IUnknown*> pCurrent;
    m_Allocator.FreeHeap();

    pCurrent = m_COMReleaseList.GetConstIterator();
     while (pCurrent.MoveNext())
    {
        pCurrent.Current()->Release();
    }

    m_COMReleaseList.Clear();
}
bool Window::getFocusList(WidgetList& wl) const {
    for(ConstIterator i = begin(); i != end(); i++) if(i->valid()) {
        EmbeddedWindow* ew = dynamic_cast<EmbeddedWindow*>(i->get());

        if(!ew) {
            if(i->get()->canFocus()) wl.push_back(i->get());
        }

        else {
            if(ew->getWindow()) ew->getWindow()->getFocusList(wl);
        }
    }

    return wl.size() != 0;
}
QString RejestracjaWydanychPsow::listaPrzydzielenPsow() const
{
    QString listaPrzydzielenPsow;
    QTextStream strumienWyjscie (&listaPrzydzielenPsow);
    ConstIterator it = constBegin();

    for ( ; it != constEnd(); ++it)
    {   strumienWyjscie << "["
        <<  it.key()->toString()   // klucz
        << "]" << " : ["
        << it.value()->toString()                        // wartość
        << "]" << endl;
    }
    return listaPrzydzielenPsow;
}
bool Window::getEmbeddedList(WindowList& wl) const {
    for(ConstIterator i = begin(); i != end(); i++) if(i->valid()) {
        EmbeddedWindow* ew = dynamic_cast<EmbeddedWindow*>(i->get());

        if(!ew || !ew->getWindow()) continue;

        else {
            wl.push_back(ew->getWindow());

            ew->getWindow()->getEmbeddedList(wl);
        }
    }

    return wl.size() != 0;
}
Example #22
0
QStringList HostConfigMap::save( KConfigBase &config ) const
{
    QStringList hostList;

    for ( ConstIterator it = begin(); it != end(); ++it ) {
        QString host = it.key();

        hostList << host;

        config.setGroup( "Host " + host );
        ( *it ).save( config );
    }

    return hostList;
}
Example #23
0
String SVGTransformList::valueAsString() const
{
    StringBuilder builder;

    ConstIterator it = begin();
    ConstIterator itEnd = end();
    while (it != itEnd) {
        builder.append(it->valueAsString());
        ++it;
        if (it != itEnd)
            builder.append(' ');
    }

    return builder.toString();
}
Example #24
0
/*******************  FUNCTION  *********************/
void ProjectActionOld::printDebug(int depth) const
{
	for (int i = 0 ; i < depth ; i++)
			cout << "\t";
	if (name == "cmrEquation")
	{
		cout << this->eq->latexName << " = " << this->eq->compute << endl;
	} else {
		if (eq != NULL)
			cout << name << " - " << description << " - " << eq->compute << ":" << endl;
		else
			cout << name << " - " << description << ":" << endl;
		for (ConstIterator it = getFirstChild() ; ! it.isEnd() ; ++it)
			it->printDebug(depth+1);
	}
}
Example #25
0
String SVGLengthList::valueAsString() const {
  StringBuilder builder;

  ConstIterator it = begin();
  ConstIterator itEnd = end();
  if (it != itEnd) {
    builder.append(it->valueAsString());
    ++it;

    for (; it != itEnd; ++it) {
      builder.append(' ');
      builder.append(it->valueAsString());
    }
  }

  return builder.toString();
}
// The topmost Window always has this method called, instead of the embedded window directly.
bool Window::setFocused(const Widget* widget) {
    // TODO: I've turned on the warn() here, but perhaps I shouldn't? I need to define
    // the conditions under which it's okay to call setFocus() with a NULL widget.
    if(!widget) {
        warn() << "Window [" << _name << "] can't focus a NULL Widget." << std::endl;

        return false;
    }

    ConstIterator i = std::find(begin(), end(), widget);

    bool found = false;

    if(i == end()) {
        // We couldn't find the widget in the toplevel, so lets see if one of our
        // EmbeddedWindow objects has it.
        WindowList wl;

        getEmbeddedList(wl);

        for(WindowList::iterator w = wl.begin(); w != wl.end(); w++) {
            ConstIterator ii = std::find(w->get()->begin(), w->get()->end(), widget);
            
            if(ii != w->get()->end()) {
                found = true;
                i     = ii;
            }
        }
    }

    else found = true;

    if(!found) {
        warn()
            << "Window [" << _name
            << "] couldn't find the Widget [" << widget->getName()
            << "] in it's object list." << std::endl
        ;

        return false;
    }

    _setFocused(i->get());

    return true;
}
Example #27
0
bool		
ChannelList::operator == (const ChannelList &other) const
{
    ConstIterator i = begin();
    ConstIterator j = other.begin();

    while (i != end() && j != other.end())
    {
	if (!(i.channel() == j.channel()))
	    return false;

	++i;
	++j;
    }

    return i == end() && j == other.end();
}
Example #28
0
void
ChannelList::layers (set <string> &layerNames) const
{
    layerNames.clear();

    for (ConstIterator i = begin(); i != end(); ++i)
    {
	string layerName = i.name();
	size_t pos = layerName.rfind ('.');

	if (pos != string::npos && pos != 0 && pos + 1 < layerName.size())
	{
	    layerName.erase (pos);
	    layerNames.insert (layerName);
	}
    }
}
Example #29
0
//! Search for step \c inStep starting at position \c inPos.
void XML::ConstFinder::search(XML::ConstIterator inPos, unsigned int inStep) {
	// stop recursion?
	if(!inPos || inStep >= mSteps.size()) return;
	// process current step
	if(mSteps[inStep] == "..") {
		// move up to parent
		if(inPos != mNode) {
			if(inStep+1 < mSteps.size()) {
				if(mSteps[inStep+1] == "..") search(inPos->getParent(), inStep+1);
				else {
					for(ConstIterator lPos = inPos->getParent()->getFirstChild(); lPos; ++lPos)
						search(lPos, inStep+1);
				}
			} else mMatches.push(inPos->getParent());
		} 
	} else if(mSteps[inStep] == "") {
		// walk tree in level order
		queue<ConstIterator> lSearchQueue;
		lSearchQueue.push(inPos);
		while(!lSearchQueue.empty()) {
			// get next node
			ConstIterator lPos = lSearchQueue.front();
			lSearchQueue.pop();
			// push all its children onto the search queue
			for(ConstIterator lChild = lPos->getFirstChild(); lChild; ++lChild) lSearchQueue.push(lChild);
			// if not last step, search recursively
			if(inStep+1 < mSteps.size()) search(lPos, inStep+1);
			else mMatches.push(lPos);
		}
	} else {
		if(mSteps[inStep] == "*" || inPos->getValue() == mSteps[inStep]) {
			// found a match
			if(inStep+1 < mSteps.size()) {
				if(mSteps[inStep+1] == "..") search(inPos, inStep+1);
				else {
					for(ConstIterator lPos = inPos->getFirstChild(); lPos; ++lPos)
						search(lPos, inStep+1);
				}
			} else mMatches.push(inPos);
		}
	}
}
bool AggregationClass::referencesData( const void* a_pContainer, const phantom::data& a_Data ) const
{
    ConstIterator* pIterator = begin(a_pContainer);
    o_assert(m_pAggregateClass->pointerType() == pIterator->getValueType());

    bool result = false;

    while(pIterator->hasNext())
    {
        const void* ptr = pIterator->pointer();
        if(pIterator->getValueType()->referencesData(ptr, a_Data))
        {
            return true;
        }
    }

    release(pIterator);

    return result;
}