本文整理汇总了C++中Batch类的典型用法代码示例。如果您正苦于以下问题:C++ Batch类的具体用法?C++ Batch怎么用?C++ Batch使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Batch类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST_F
TEST_F(MapaDBTest, noDeberiaEjecutarBatchEnQueFallaraUnaAccion) {
Batch batch;
batch.put("key", "value");
batch.modify("key2", "value2"); // No existe key2, este falla
EXPECT_FALSE(db->writeBatch(batch));
EXPECT_THROW(db->get("key"), KeyNotFound);
}
示例2: switch
void GLBackend::renderPassDraw(Batch& batch) {
_transform._objectsItr = _transform._objectOffsets.begin();
_transform._camerasItr = _transform._cameraOffsets.begin();
const size_t numCommands = batch.getCommands().size();
const Batch::Commands::value_type* command = batch.getCommands().data();
const Batch::CommandOffsets::value_type* offset = batch.getCommandOffsets().data();
for (_commandIndex = 0; _commandIndex < numCommands; ++_commandIndex) {
switch (*command) {
// Ignore these commands on this pass, taken care of in the transfer pass
// Note we allow COMMAND_setViewportTransform to occur in both passes
// as it both updates the transform object (and thus the uniforms in the
// UBO) as well as executes the actual viewport call
case Batch::COMMAND_setModelTransform:
case Batch::COMMAND_setViewTransform:
case Batch::COMMAND_setProjectionTransform:
break;
default: {
CommandCall call = _commandCalls[(*command)];
(this->*(call))(batch, *offset);
break;
}
}
command++;
offset++;
}
}
示例3: render
void GLBackend::render(const Batch& batch) {
_transform._skybox = _stereo._skybox = batch.isSkyboxEnabled();
// Allow the batch to override the rendering stereo settings
// for things like full framebuffer copy operations (deferred lighting passes)
bool savedStereo = _stereo._enable;
if (!batch.isStereoEnabled()) {
_stereo._enable = false;
}
// Reset jitter
_transform._projectionJitter = Vec2(0.0f, 0.0f);
{
PROFILE_RANGE(render_gpu_gl_detail, "Transfer");
renderPassTransfer(batch);
}
#ifdef GPU_STEREO_DRAWCALL_INSTANCED
if (_stereo.isStereo()) {
glEnable(GL_CLIP_DISTANCE0);
}
#endif
{
PROFILE_RANGE(render_gpu_gl_detail, _stereo.isStereo() ? "Render Stereo" : "Render");
renderPassDraw(batch);
}
#ifdef GPU_STEREO_DRAWCALL_INSTANCED
if (_stereo.isStereo()) {
glDisable(GL_CLIP_DISTANCE0);
}
#endif
// Restore the saved stereo state for the next batch
_stereo._enable = savedStereo;
}
示例4: armarBatchEliminarArchivo
Batch ManejadorMetadatos::armarBatchEliminarArchivo (const string& jsonMetadatos, const string& username,
const string& filepath, const string& pathCompletoPapelera) {
Batch batch;
string jsonMetadatosConFechaModif = this->actualizarUsuarioFechaModificacion(jsonMetadatos, username);
MetadatoArchivo metadatoConFechaModif = ParserJson::deserializarMetadatoArchivo(jsonMetadatosConFechaModif);
for (auto &usuario : metadatoConFechaModif.usuariosHabilitados) {
if (usuario == metadatoConFechaModif.propietario)
continue;
string permisosUsuario = PERMISOS + "/" + usuario;
if (validador->existeMetadato(permisosUsuario)) {
string archivosStr = dbMetadatos->get(permisosUsuario);
vector<string> archivos = ParserURI::parsear(archivosStr, RESERVED_CHAR);
archivos.erase(remove(archivos.begin(), archivos.end(), filepath), archivos.end());
string joined = ParserURI::join(archivos, RESERVED_CHAR);
batch.modify(permisosUsuario, joined);
} else {
Logger::logWarn("No existe en dbMetadatos " + permisosUsuario + " al armar batch de eliminar archivo");
}
}
metadatoConFechaModif.usuariosHabilitados.clear();
metadatoConFechaModif.usuariosHabilitados.push_back(metadatoConFechaModif.propietario);
string nuevoJson = ParserJson::serializarMetadatoArchivo(metadatoConFechaModif);
batch.erase(filepath);
batch.put(pathCompletoPapelera, nuevoJson);
return batch;
}
示例5: agregarPermiso
bool ManejadorMetadatos::agregarPermiso (string usernameOrigen, string filepath, string usernameDestino) {
if (not validador->verificarPermisos(usernameOrigen, filepath))
return false;
if (not dbMetadatos->contains(filepath)) {
Logger::logWarn("Se quiso agregar un permiso al archivo " + filepath + " pero este no existe.");
return false;
}
string pathPermisos = PERMISOS + "/" + usernameDestino;
if (not dbMetadatos->contains(pathPermisos)) {
Logger::logWarn("Se quiso agregar un permiso al usuario " + usernameDestino + " pero este no existe.");
return false;
}
string jsonArchivo = dbMetadatos->get(filepath);
MetadatoArchivo metadato = ParserJson::deserializarMetadatoArchivo(jsonArchivo);
metadato.usuariosHabilitados.push_back(usernameDestino);
string jsonModificado = ParserJson::serializarMetadatoArchivo(metadato);
Batch batch;
batch.modify(filepath, jsonModificado);
// Como este metodo se llama directamente desde actualizarMetadatos, ya la fecha viene modificada
string archivosPermitidos = dbMetadatos->get(pathPermisos);
if (archivosPermitidos != "")
archivosPermitidos += RESERVED_CHAR;
archivosPermitidos += filepath;
batch.modify(pathPermisos, archivosPermitidos);
dbMetadatos->writeBatch(batch);
return true;
}
示例6: render
void GLBackend::render(Batch& batch) {
// Finalize the batch by moving all the instanced rendering into the command buffer
batch.preExecute();
_stereo._skybox = batch.isSkyboxEnabled();
// Allow the batch to override the rendering stereo settings
// for things like full framebuffer copy operations (deferred lighting passes)
bool savedStereo = _stereo._enable;
if (!batch.isStereoEnabled()) {
_stereo._enable = false;
}
{
PROFILE_RANGE("Transfer");
renderPassTransfer(batch);
}
{
PROFILE_RANGE(_stereo._enable ? "LeftRender" : "Render");
renderPassDraw(batch);
}
if (_stereo._enable) {
PROFILE_RANGE("RightRender");
_stereo._pass = 1;
renderPassDraw(batch);
_stereo._pass = 0;
}
// Restore the saved stereo state for the next batch
_stereo._enable = savedStereo;
}
示例7: addCube
void Chunk::addCube(Batch& batch, uint8_t x, uint8_t y, uint8_t z)
{
std::vector<glm::vec3> vertices(6 * 6);
std::vector<glm::vec2> texCoords(6 * 6);
glm::vec3 v0(x, y, z);
glm::vec3 v1(x, y + 1.0f, z);
glm::vec3 v2(x + 1.0f, y, z);
glm::vec3 v3(x + 1.0f, y + 1.0f, z);
glm::vec3 v4(x, y + 1.0f, z + 1.0f);
glm::vec3 v5(x, y, z + 1.0f);
glm::vec3 v6(x + 1.0f, y, z + 1.0f);
glm::vec3 v7(x + 1.0f, y + 1.0f, z + 1.0f);
glm::vec2 t0(0.0f, 0.0f);
glm::vec2 t1(0.0f, 1.0f);
glm::vec2 t2(1.0f, 0.0f);
glm::vec2 t3(1.0f, 1.0f);
// Front Face
vertices.push_back(v1); vertices.push_back(v0); vertices.push_back(v2);
texCoords.push_back(t1); texCoords.push_back(t0); texCoords.push_back(t2);
vertices.push_back(v2); vertices.push_back(v3); vertices.push_back(v1);
texCoords.push_back(t2); texCoords.push_back(t3); texCoords.push_back(t1);
// Right Face
vertices.push_back(v3); vertices.push_back(v2); vertices.push_back(v6);
texCoords.push_back(t1); texCoords.push_back(t0); texCoords.push_back(t2);
vertices.push_back(v6); vertices.push_back(v7); vertices.push_back(v3);
texCoords.push_back(t2); texCoords.push_back(t3); texCoords.push_back(t1);
// Back Face
vertices.push_back(v7); vertices.push_back(v6); vertices.push_back(v5);
texCoords.push_back(t1); texCoords.push_back(t0); texCoords.push_back(t2);
vertices.push_back(v5); vertices.push_back(v4); vertices.push_back(v7);
texCoords.push_back(t2); texCoords.push_back(t3); texCoords.push_back(t1);
// Left Face
vertices.push_back(v4); vertices.push_back(v5); vertices.push_back(v0);
texCoords.push_back(t1); texCoords.push_back(t0); texCoords.push_back(t2);
vertices.push_back(v0); vertices.push_back(v1); vertices.push_back(v4);
texCoords.push_back(t2); texCoords.push_back(t3); texCoords.push_back(t1);
// Top Face
vertices.push_back(v4); vertices.push_back(v1); vertices.push_back(v3);
texCoords.push_back(t1); texCoords.push_back(t0); texCoords.push_back(t2);
vertices.push_back(v3); vertices.push_back(v7); vertices.push_back(v4);
texCoords.push_back(t2); texCoords.push_back(t3); texCoords.push_back(t1);
// Bottom Face
vertices.push_back(v0); vertices.push_back(v5); vertices.push_back(v6);
texCoords.push_back(t1); texCoords.push_back(t0); texCoords.push_back(t2);
vertices.push_back(v6); vertices.push_back(v2); vertices.push_back(v0);
texCoords.push_back(t2); texCoords.push_back(t3); texCoords.push_back(t1);
batch.vertices(vertices);
batch.textures(texCoords);
}
示例8: restaurarMetadatos
bool ManejadorMetadatos::restaurarMetadatos (const string& pathEnPapeleraSinFS, const string& username,
const string& pathRealSinFS) {
string metadatosJson = dbMetadatos->get(pathEnPapeleraSinFS);
string nuevosMetadatosJson = this->actualizarUsuarioFechaModificacion(metadatosJson, username);
Batch batch;
batch.erase(pathEnPapeleraSinFS);
batch.put(pathRealSinFS, nuevosMetadatosJson);
return dbMetadatos->writeBatch(batch);
}
示例9: insertIter
nsresult sbMockDevice::ProcessBatch(Batch & aBatch)
{
std::insert_iterator<std::vector<nsRefPtr<sbRequestItem> > >
insertIter(mBatch, mBatch.end());
std::copy(aBatch.begin(), aBatch.end(), insertIter);
/* don't process, let the js deal with it */
return NS_OK;
}
示例10: PROFILE_RANGE
void GLBackend::renderPassTransfer(Batch& batch) {
const size_t numCommands = batch.getCommands().size();
const Batch::Commands::value_type* command = batch.getCommands().data();
const Batch::CommandOffsets::value_type* offset = batch.getCommandOffsets().data();
{ // Sync all the buffers
PROFILE_RANGE("syncGPUBuffer");
for (auto& cached : batch._buffers._items) {
if (cached._data) {
syncGPUObject(*cached._data);
}
}
}
{ // Sync all the buffers
PROFILE_RANGE("syncCPUTransform");
_transform._cameras.clear();
_transform._cameraOffsets.clear();
for (_commandIndex = 0; _commandIndex < numCommands; ++_commandIndex) {
switch (*command) {
case Batch::COMMAND_draw:
case Batch::COMMAND_drawIndexed:
case Batch::COMMAND_drawInstanced:
case Batch::COMMAND_drawIndexedInstanced:
case Batch::COMMAND_multiDrawIndirect:
case Batch::COMMAND_multiDrawIndexedIndirect:
_transform.preUpdate(_commandIndex, _stereo);
break;
case Batch::COMMAND_setViewportTransform:
case Batch::COMMAND_setViewTransform:
case Batch::COMMAND_setProjectionTransform: {
CommandCall call = _commandCalls[(*command)];
(this->*(call))(batch, *offset);
break;
}
default:
break;
}
command++;
offset++;
}
}
{ // Sync the transform buffers
PROFILE_RANGE("syncGPUTransform");
_transform.transfer(batch);
}
}
示例11: lk
void OplogBufferCollection::pushEvenIfFull(OperationContext* txn, const Value& value) {
// This oplog entry is a sentinel
if (value.isEmpty()) {
stdx::lock_guard<stdx::mutex> lk(_mutex);
_sentinels.push(_lastPushedTimestamp);
_count++;
_cvNoLongerEmpty.notify_all();
return;
}
Batch valueBatch = {value};
pushAllNonBlocking(txn, valueBatch.begin(), valueBatch.end());
}
示例12: TRACE_FUNCTION
nsresult sbRequestThreadQueue::PopBatch(Batch & aBatch)
{
TRACE_FUNCTION("");
NS_ENSURE_STATE(mLock);
nsAutoLock lock(mLock);
aBatch.clear();
// If nothing was found then just return with an empty batch
if (mRequestQueue.empty()) {
LOG("No requests found\n");
return NS_OK;
}
// If we're in the middle of a batch just return an empty batch
if (mBatchDepth > 0) {
LOG("Waiting on batch to complete\n");
return NS_OK;
}
RequestQueue::iterator queueIter = mRequestQueue.begin();
// request queue holds on to the object
sbRequestItem * request = *queueIter;
// If this isn't countable just return it by itself
if (!request->GetIsCountable()) {
LOG("Single non-batch request found\n");
aBatch.push_back(request);
mRequestQueue.erase(queueIter);
// Release our reference to the request, aBatch is holding a reference to it
NS_RELEASE(request);
return NS_OK;
}
const PRUint32 requestBatchId = request->GetBatchId();
// find the end of the batch and keep track of the matching batch entries
const RequestQueue::const_iterator queueEnd = mRequestQueue.end();
while (queueIter != queueEnd &&
requestBatchId == (*queueIter)->GetBatchId()) {
request = *queueIter++;
aBatch.push_back(request);
// Release our reference to the request, aBatch is holding a reference to it
NS_RELEASE(request);
}
// Remove all the items we pushed onto the batch
mRequestQueue.erase(mRequestQueue.begin(), queueIter);
return NS_OK;
}
示例13: actualizarPermisosPathArchivo
void ManejadorMetadatos::actualizarPermisosPorRenombrado (const string& filepath, const string& nuevoFilename,
const MetadatoArchivo& metadatosNuevos, const string& nuevoJson) {
MetadatoArchivo metadatosViejos = ParserJson::deserializarMetadatoArchivo(dbMetadatos->get(filepath));
string nuevoFilepath = ParserURI::pathConNuevoFilename(filepath, nuevoFilename);
list<string> usuariosHabilitados = (metadatosNuevos.usuariosHabilitados.empty()) ?
metadatosViejos.usuariosHabilitados : metadatosNuevos.usuariosHabilitados;
usuariosHabilitados.remove(metadatosNuevos.propietario);
if ( not usuariosHabilitados.empty() ) //Si estaba compartido
actualizarPermisosPathArchivo(filepath, nuevoFilepath, usuariosHabilitados); // actualiza el path del archivo en quienes tienen permiso
Batch batch;
batch.erase(filepath);
batch.put(nuevoFilepath, nuevoJson);
dbMetadatos->writeBatch(batch);
}
示例14: lock
BatchPointer Context::acquireBatch(const char* name) {
Batch* rawBatch = nullptr;
{
Lock lock(_batchPoolMutex);
if (!_batchPool.empty()) {
rawBatch = _batchPool.front();
_batchPool.pop_front();
}
}
if (!rawBatch) {
rawBatch = new Batch();
}
rawBatch->setName(name);
return BatchPointer(rawBatch, [this](Batch* batch) { releaseBatch(batch); });
}
示例15: update_batch_tools
void RecordGUI::update_batch_tools()
{
//printf("RecordGUI::update_batch_tools 1\n");
char string[BCTEXTLEN];
Batch *batch = record->get_editing_batch();
batch_path->update(batch->get_current_asset()->path);
// File is open in editing batch
// if(record->current_batch == record->editing_batch && record->file)
// batch_path->disable();
// else
// batch_path->enable();
batch_start->update(&batch->start_day, &batch->start_time);
batch_duration->update(0, &batch->duration);
batch_source->update(batch->get_source_text());
batch_mode->update(Batch::mode_to_text(batch->record_mode));
flush();
}