Esempio n. 1
0
// ----------------------------------------------------------------------------
// ArchiveEntryList::sortItems
//
// Sorts the list items depending on the current sorting column
// ----------------------------------------------------------------------------
void ArchiveEntryList::sortItems()
{
	lv_current = this;
	std::sort(items.begin(), items.end(), [&](long left, long right)
	{
		auto le = getEntry(left, false);
		auto re = getEntry(right, false);

		// Check entries exist (just to be needlessly safe)
		if (!le || !re)
			return sort_descend ? right < left : left < right;

		// Sort folder->entry first
		if (le->getType() == EntryType::folderType() && re->getType() != EntryType::folderType())
			return true;
		if (re->getType() == EntryType::folderType() && le->getType() != EntryType::folderType())
			return false;

		// Sort folder<->folder or entry<->entry
		int result = 0;

		// Size sort
		if (col_size >= 0 && col_size == sortColumn())
			result = entrySize(left) - entrySize(right);

		// Index sort
		else if (col_index >= 0 && col_index == sortColumn())
			result = 0;

		// Name sort
		else if (col_name >= 0 && col_name == sortColumn())
		{
			const wxChar* reName = re->getName().c_str();
			result = le->getName().CompareTo(reName, string::ignoreCase);
		}

		// Other (default) sort
		else
			return VirtualListView::defaultSort(left, right);

		// If sort values are equal, just sort by index
		if (result == 0)
			result = left - right;

		return sort_descend ? result > 0 : result < 0;
	});
}
Esempio n. 2
0
File: sstable.c Progetto: pipul/lab
int32_t sstBlockSize(sstblock_t *list)
{
    entry_t *node;
    int32_t bsize;

    if (!list)
        return(-1);
    bsize = sizeof(uint64_t);
    for (node = sstBlockHeader(list); node != NULL; node = entryNext(node))
        bsize = bsize + entrySize(node);
    return(bsize);
}
Esempio n. 3
0
void MlCache::setCachedSlices(const std::string & name)
{
	openEntry(name);
	HBase * p = getNamedEntry(name);
	int nf = p->numChildren();
	unsigned csize = entrySize(name);
	for(int i = 0; i < nf; i++) {
		if(p->isChildData(i))
			setCached(name, p->getChildName(i), csize);
	}
	
	closeEntry(name);
}
Esempio n. 4
0
// Cache manager should invalidate the entry on false
bool CurlCacheEntry::isCached()
{
    if (!fileExists(m_contentFilename) || !fileExists(m_headerFilename))
        return false;

    if (!m_headerParsed) {
        if (!loadResponseHeaders())
            return false;
    }

    if (m_expireDate < currentTimeMS()) {
        m_headerParsed = false;
        return false;
    }

    if (!entrySize())
        return false;

    return true;
}
Esempio n. 5
0
bool MlCache::doCopy(const std::string & name)
{
	std::cout<<"copy cache to "<<name;

	useDocument();
	openEntry("/ang");
	int nang = entrySize("/ang");

	if(nang < 1) return false;
	
	std::vector<std::string> sliceNames;
	unsigned numSlices = cacheSliceNames("/ang", sliceNames);
	std::cout<<" n slice "<<numSlices<<"in /ang\n";
	if(numSlices < 2) return false;
	
	openEntry("/tang");
	int tsize = entrySize("/tang");
	openEntry("/p");
	int ptsize = entrySize("/p");
	
	MlCache tgt;
	if(!tgt.create(name)) return false;
	
	tgt.useDocument();
	tgt.openEntry("/info");
	HBase *info = tgt.getNamedEntry("/info");
	info->addStringAttr(".scene", m_sceneName.size());
	info->writeStringAttr(".scene", m_sceneName);
	info->addIntAttr(".range", 2);
	info->writeIntAttr(".range", m_bakeRange);
	tgt.closeEntry("/info");
	
	tgt.openEntry("/ang");
	tgt.saveEntrySize("/ang", nang);
	
	tgt.openEntry("/tang");
	tgt.saveEntrySize("/tang", tsize);
	
	tgt.openEntry("/p");
	tgt.saveEntrySize("/p", ptsize);
	
	const unsigned blockL = 4096;
	float * b = new float[blockL];
	Vector3F * bp = new Vector3F[blockL];
	Matrix33F * bm = new Matrix33F[blockL];
	
	BoundingBox box;
	Vector3F center;
	unsigned i, j, start, count;
	for(i = 0; i < sliceNames.size(); i++) {
		std::string aslice = HObject::PartialPath("/ang", sliceNames[i]);
		if(aslice == "-9999") continue;
		
		useDocument();
		openSliceFloat("/ang", aslice);
		openSliceVector3("/p", aslice);
		openSliceMatrix33("/tang", aslice);
		
		tgt.useDocument();
		tgt.openSliceFloat("/ang", aslice);
		tgt.openSliceVector3("/p", aslice);
		tgt.openSliceMatrix33("/tang", aslice);
		
		start = 0;
		count = blockL;
		for(j = 0; j <= nang/blockL; j++) {
			if(j== nang/blockL)
				count = nang%blockL;
				
			start = j * blockL;

			useDocument();
			readSliceFloat("/ang", aslice, start, count, b);
		
			tgt.useDocument();
			tgt.writeSliceFloat("/ang", aslice, start, count, b);
		}
		
		start = 0;
		count = blockL;
		for(j = 0; j <= tsize/blockL; j++) {
			if(j== tsize/blockL)
				count = tsize%blockL;
				
			start = j * blockL;	
			useDocument();
			readSliceVector3("/p", aslice, start, count, bp);
			readSliceMatrix33("/tang", aslice, start, count, bm);
			
			tgt.useDocument();
			tgt.writeSliceVector3("/p", aslice, start, count, bp);
			tgt.writeSliceMatrix33("/tang", aslice, start, count, bm);

		}
		
		useDocument();
		closeSlice("/ang", aslice);
		closeSlice("/tang", aslice);
		closeSlice("/p", aslice);
		tgt.useDocument();
		tgt.closeSlice("/ang", aslice);
		tgt.closeSlice("/tang", aslice);
		tgt.closeSlice("/p", aslice);
		
		getBounding(aslice, box);
		getTranslation(aslice, center);
		
		tgt.setBounding(aslice, box);
		tgt.setTranslation(aslice, center);
		tgt.flush();
	}
	delete[] b;
	delete[] bp;
	delete[] bm;
	
	useDocument();
	closeEntry("/ang");
	closeEntry("/tang");
	closeEntry("/p");
	
	tgt.useDocument();
	tgt.closeEntry("/ang");
	tgt.closeEntry("/tang");
	tgt.closeEntry("/p");
	
	tgt.close();
	return true;
}