Example #1
0
/**
* Creates a list of all events.
**/
std::string generateEventsTable(const std::list<Event>& events)
{
	std::ostringstream ss;

	unsigned int counter = 1;

	char timeBuffer[100] = {0};
	char timeline[26];

	for (std::list<Event>::const_iterator Iter = events.begin(); Iter != events.end(); ++Iter)
	{
		createRow(ss, counter);

		createCell(ss, counter, "center");

		_timeb eventTime = Iter->getTime();
		ctime_s( timeline, 26, & ( eventTime.time ) );

		sprintf(timeBuffer, "%.8s.%hu", timeline + 11, eventTime.millitm);

		createCell(ss, timeBuffer, "center");

		ss << "<td style=\"text-align:center\">";
		ss << "0x" << std::uppercase << std::hex << Iter->getAddress().getAddress() << std::dec << std::nouppercase;
		ss << "</td>";

		createCell(ss, Iter->getParentFunction().getName(), "left");

		++counter;
	}

	return ss.str();
}
Example #2
0
 bool updateLeavesSpawn() {
     bool fullGridSpawn = (newLeaves.size() == (unsigned)theHeriswapGridSystem.GridSize*theHeriswapGridSystem.GridSize);
     ADSR(haveToAddLeavesInGrid)->active = true;
     for ( std::vector<Feuille>::reverse_iterator it = newLeaves.rbegin(); it != newLeaves.rend(); ++it ) {
         if (it->entity == 0) {
             it->entity = createCell(*it, fullGridSpawn);
         } else {
             HeriswapGridComponent* gc = HERISWAPGRID(it->entity);
             if (fullGridSpawn) {
                 gc->i = gc->j = -1;
             }
             TransformationComponent* tc = TRANSFORM(it->entity);
             //leaves grow up from 0 to fixed size
             glm::vec2 s = HeriswapGame::CellSize(theHeriswapGridSystem.GridSize, gc->type);
             if (ADSR(haveToAddLeavesInGrid)->value == 1){
                 tc->size = glm::vec2(s.x, s.y);
                 gc->i = it->X;
                 gc->j = it->Y;
             } else {
                 tc->size = s * ADSR(haveToAddLeavesInGrid)->value;
             }
         }
     }
     return (ADSR(haveToAddLeavesInGrid)->value == 1);
 }
ossimRefPtr<ossimElevCellHandler> ossimElevationCellDatabase::getOrCreateCellHandler(const ossimGpt& gpt)
{
  ossimRefPtr<ossimElevCellHandler> result = 0;
  ossim_uint64 id = createId(gpt);
  
  {
    OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_cacheMapMutex);
    CellMap::iterator iter = m_cacheMap.find(id);
    if(iter != m_cacheMap.end())
    {
      iter->second->updateTimestamp();
      result = iter->second->m_handler.get();
      
      return result.get();
    }
  }
  
  result = createCell(gpt);
  
  {
    OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_cacheMapMutex);
    if(result.valid())
    {
      m_cacheMap.insert(std::make_pair(id, new CellInfo(id, result.get())));

      // Check the map size and purge cells if needed.
      if(m_cacheMap.size() > m_maxOpenCells)
      {
         flushCacheToMinOpenCells();
      }
    }
  }

  return result;
}
Example #4
0
	///----------------------------------------------------------------------------//
	///--------------------- ENTER SECTION ----------------------------------------//
	///----------------------------------------------------------------------------//
	void onPreEnter(Scene::Enum from) override {
        // Prepare game
        if (from == Scene::CountDown) {
            game->datas->faderHelper.start(Fading::In, 0.5);
        }

		ADSR(haveToAddLeavesInGrid)->attackTiming = game->datas->timing.haveToAddLeavesInGrid;
        ADSR(replaceGrid)->attackTiming = game->datas->timing.replaceGrid;

		fillTheBlank(newLeaves);

		//we need to create the whole grid (start game and level change)
		if ((int)newLeaves.size() == theHeriswapGridSystem.GridSize*theHeriswapGridSystem.GridSize) {
	     	LOGI("create '" << newLeaves.size() << "' cells");
			for(unsigned int i=0; i<newLeaves.size(); i++) {
	            if (newLeaves[i].entity == 0)
				    newLeaves[i].entity = createCell(newLeaves[i], true);
			}
	        ADSR(haveToAddLeavesInGrid)->active = true;
			removeEntitiesInCombination();
		} else {
		    ADSR(haveToAddLeavesInGrid)->active = false;
	    }
	    ADSR(haveToAddLeavesInGrid)->activationTime = 0;

		ADSR(replaceGrid)->activationTime = 0;
		ADSR(replaceGrid)->active = false;
	}
Example #5
0
GLECSVDataStatus GLECSVData::readCellString(GLEBYTE quote) {
	unsigned int cellSize = 1;
	unsigned int cellPos = lastCharPos();
	initWritePos();
	while (true) {
		GLEBYTE ch = readChar();
		writeChar(ch);
		cellSize++;
		if (ch == 0) {
			m_error.errorCode = GLECSVErrorUnterminatedString;
			m_error.errorLine = m_lines;
			m_error.errorColumn = getUTF8Column(cellPos);
			createErrorString("unterminated string");
			return GLECSVDataStatusEOF;
		} else if (isEol(ch)) {
			m_error.errorCode = GLECSVErrorUnterminatedString;
			m_error.errorLine = m_lines;
			m_error.errorColumn = getUTF8Column(cellPos);
			createErrorString("unterminated string");
			return readNewline(ch);
		} else if (ch == quote) {
			GLEBYTE ch = readChar();
			if (ch != quote) {
				writeChar(ch);
				createCell(cellSize, cellPos);
				return skipSpacesAndFirstDelim(ch);
			}
		}
	}
	return GLECSVDataStatusOK;
}
Example #6
0
void WTableRow::insertColumn(int column)
{
  cells_.insert(cells_.begin() + column, createCell(column));
  WTableCell *cell = cells_[column].get();
  if (table_)
    table_->widgetAdded(cell);
  cell->row_ = this;
  cell->column_ = column;

  for (unsigned i = column; i < cells_.size(); ++i)
    cells_[i]->column_ = i;
}
Example #7
0
void WTableRow::expand(int numCells)
{
  int cursize = cells_.size();
  for (int col = cursize; col < numCells; ++col) {
    cells_.push_back(createCell(col));
    WTableCell *cell = cells_.back().get();
    if (table_)
      table_->widgetAdded(cell);
    cell->row_ = this;
    cell->column_ = col;
  }
}
Example #8
0
GLECSVDataStatus GLECSVData::readCell() {
	GLEBYTE ch = readSignificantChar();
	if (ch == '"' || ch == '\'') {
		return readCellString(ch);
	}
	unsigned int cellCount = 0;
	unsigned int cellSize = 0;
	unsigned int cellPos = lastCharPos();
	while (true) {
		if (ch == 0) {
			if (isSizeCheckOKEndOfLine(cellSize)) {
				createCell(cellSize, cellPos);
			}
			return GLECSVDataStatusEOF;
		} else if (isEol(ch)) {
			if (isSizeCheckOKEndOfLine(cellSize)) {
				createCell(cellSize, cellPos);
			}
			return readNewline(ch);
		} else if (isDelim(ch)) {
			m_lastDelimWasSpace = isSpace(ch);
			if (isSizeCheckOKAtDelim(ch, cellSize)) {
				createCell(cellSize, cellPos);
			}
			return skipSpacesAndFirstDelim(ch);
		} else if (isComment(ch)) {
			if (isSizeCheckOKEndOfLine(cellSize)) {
				createCell(cellSize, cellPos);
			}
			return skipTillEol();
		}
		cellCount++;
		if (!isSpace(ch)) {
			cellSize = cellCount;
		}
		ch = readChar();
	}
	return GLECSVDataStatusOK;
}
Example #9
0
/** \brief Create the grid with char from a file
 *
 * \param Cell[][] : array of Cell
 * \param char[][] : array of char
 *
 */
void createGrid(Cell grid[N][N], char charFile[]) {

    int i, j;
    int x = 0;

    for (i = 0; i < N; i++) {

        for (j = 0; j < N; j++) {

            grid[i][j] = createCell(charFile[x]);
            x++;
        }
    }
}
Example #10
0
	HashCell *addCell(HashCell *cell, StringXXX *key){
		HashCell *tmp = cell;
		while (tmp != nullptr){
			if (areEqual(tmp->key, key)){
				tmp->howMuch++;
				deleteString(key);
				return cell;
			}
			tmp = tmp->next;
		}
		HashCell *newCell = createCell(key);
		newCell->next = cell;
		newCell->howMuch++;
		return newCell;
	}
Example #11
0
/**
* Generates a HTML table that is used to display function events sorted by a given sorter.
**/
std::string generateFunctionTable(std::list<TimedBlock*>& functionResults, bool (*sorter)(const TimedBlock*, const TimedBlock*))
{
	functionResults.sort(sorter);

	time_t totalTime = ::totalTime(functionResults);
	unsigned int totalHits = ::totalHits(functionResults);

	std::ostringstream ss;

	unsigned int counter = 1;

	for (std::list<TimedBlock*>::const_iterator Iter = functionResults.begin(); Iter != functionResults.end(); ++Iter)
	{
		TimedBlock* bb = *Iter;

		if (bb->getHits() == 0)
		{
			// We can not break here because it's not guaranteed that useful events come later,
			// depending on the exact sort algorithm.
			continue;
		}

		createRow(ss, counter);

		createCell(ss, counter, "center");
		createCell(ss, bb->getParentFunction().getName(), "left");

		ss << "<td style=\"text-align:center\">";
		ss << "0x" << std::uppercase << std::hex << bb->getParentFunction().getAddress().getAddress() << std::nouppercase;
		ss << "</td>";

		ss << std::dec << std::fixed << std::setprecision(2);
		createCell(ss, bb->getTime(), "right", " ms");

		createCell(ss, 100.0 * bb->getTime() / totalTime, "right", " %");
		createCell(ss, bb->getHits(), "right");
		createCell(ss, 100.0 * bb->getHits() / totalHits, "right", " %");
		createCell(ss, 1.0 * bb->getTime() / bb->getHits(), "right", " ms");

		ss << "</tr>";

		++counter;
	}

	return ss.str();
}
Example #12
0
void Column::insertRow(const RowId& newRowId, int index)
{
  ICell* pNewCell = createCell(newRowId, index);

  m_cells.insert(m_cells.begin()+index, pNewCell);
}
Example #13
0
Cell::Cell(int _iDims, const int* _piDims, InternalType** data)
{
    createCell(_iDims, _piDims, data);
}
Example #14
0
Cell::Cell(int _iRows, int _iCols, InternalType** data)
{
    int piDims[2] = {_iRows, _iCols};
    createCell(2, piDims, data);
}
Example #15
0
/**
** Constructor & Destructor (public)
*/
Cell::Cell()
{
    int piDims[2] = {0, 0};
    createCell(2, piDims, nullptr);
}
ossimRefPtr<ossimElevCellHandler> ossimImageElevationDatabase::getOrCreateCellHandler(
   const ossimGpt& gpt)
{
   ossimRefPtr<ossimElevCellHandler> result = 0;
   
   // Note: Must do mutex lock / unlock around any cach map access.
   m_cacheMapMutex.lock();

   if ( m_cacheMap.size() )
   {
      //---
      // Look in existing map for handler.
      //
      // Note: Cannot key off of id from gpt as cells can be any arbituary dimensions.
      //---

      CellMap::iterator lastAccessedCellIter = m_cacheMap.find(m_lastAccessedId);
      CellMap::iterator iter = lastAccessedCellIter;
        
      // Check from last accessed to end.
      while ( iter != m_cacheMap.end() )
      {
         if ( iter->second->m_handler->pointHasCoverage(gpt) )
         {
            result = iter->second->m_handler.get();
            break;
         }
         ++iter;
      }
     
      if ( result.valid() == false )
      {
         iter = m_cacheMap.begin();
              
         // Beginning to last accessed.
         while ( iter != lastAccessedCellIter)
         {
            if ( iter->second->m_handler->pointHasCoverage(gpt) )
            {
               result = iter->second->m_handler.get();
               break;
            }
            ++iter;
         }
      }

      if ( result.valid() )
      {
         m_lastAccessedId  = iter->second->m_id;
         iter->second->updateTimestamp();
      }
   }
   m_cacheMapMutex.unlock();
  
   if ( result.valid() == false )
   {
      // Not in m_cacheMap.  Create a new cell for point if we have coverage.
      result = createCell(gpt);

      if(result.valid())
      {
         OpenThreads::ScopedLock<OpenThreads::Mutex> lock(m_cacheMapMutex);

         //---
         // Add the cell to map.
         // NOTE: ossimImageElevationDatabase::createCell sets m_lastAccessedId to that of
         // the entries map key.
         //---
         m_cacheMap.insert(std::make_pair(m_lastAccessedId,
                                          new CellInfo(m_lastAccessedId, result.get())));

         ++m_lastMapKey;

         // Check the map size and purge cells if needed.
         if(m_cacheMap.size() > m_maxOpenCells)
         {
            flushCacheToMinOpenCells();
         }
      }
   }

   return result;
}