当前位置: 首页>>代码示例>>C++>>正文


C++ RepoBSONBuilder类代码示例

本文整理汇总了C++中RepoBSONBuilder的典型用法代码示例。如果您正苦于以下问题:C++ RepoBSONBuilder类的具体用法?C++ RepoBSONBuilder怎么用?C++ RepoBSONBuilder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了RepoBSONBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: makeRepoRoleSettings

RepoRoleSettings RepoBSONFactory::makeRepoRoleSettings(
	const std::string &uniqueRoleName,
	const std::string &color,
	const std::string &description,
	const std::vector<std::string> &modules)
{
	RepoBSONBuilder builder;

	//--------------------------------------------------------------------------
	// Project name
	if (!uniqueRoleName.empty())
		builder << REPO_LABEL_ID << uniqueRoleName;

	// Color
	if (!color.empty())
		builder << REPO_LABEL_COLOR << color;

	// Description
	if (!description.empty())
		builder << REPO_LABEL_DESCRIPTION << description;

	// Modules
	if (modules.size() > 0)
		builder.appendArray(REPO_LABEL_MODULES, modules);

	return RepoRoleSettings(builder.obj());
}
开发者ID:3drepo,项目名称:3drepobouncer,代码行数:27,代码来源:repo_bson_factory.cpp

示例2: TEST

TEST(RepoBSONTest, AppendDefaultsTest)
{
	RepoBSONBuilder builder;

	RepoBSONFactory::appendDefaults(
		builder, "test");

	RepoNode n = builder.obj();

	EXPECT_FALSE(n.isEmpty());

	EXPECT_EQ(4, n.nFields()); 

	EXPECT_TRUE(n.hasField(REPO_NODE_LABEL_ID));
	EXPECT_TRUE(n.hasField(REPO_NODE_LABEL_SHARED_ID));
	EXPECT_TRUE(n.hasField(REPO_NODE_LABEL_API));
	EXPECT_TRUE(n.hasField(REPO_NODE_LABEL_TYPE));

	//Ensure existing fields doesnt' disappear

	RepoBSONBuilder builderWithFields;

	builderWithFields << "Number" << 1023;
	builderWithFields << "doll" << "Kitty";

	RepoBSONFactory::appendDefaults(
		builderWithFields, "test");

}
开发者ID:wsdflink,项目名称:3drepobouncer,代码行数:29,代码来源:ut_repo_bson_factory.cpp

示例3: loadStash

bool RepoScene::loadStash(
	repo::core::handler::AbstractDatabaseHandler *handler,
	std::string &errMsg){
	bool success = true;

	if (!handler)
	{
		errMsg += "Trying to load stash graph without a database handler!";
		return false;
	}

	if (!revNode){
		if (!loadRevision(handler, errMsg)) return false;
	}

	//Get the relevant nodes from the scene graph using the unique IDs stored in this revision node
	RepoBSONBuilder builder;
	builder.append(REPO_NODE_STASH_REF, revNode->getUniqueID());

	std::vector<RepoBSON> nodes = handler->findAllByCriteria(databaseName, projectName + "." + stashExt, builder.obj());
	if (success = nodes.size())
	{
		repoInfo << "# of nodes in this stash scene = " << nodes.size();
		success = populate(GraphType::OPTIMIZED, handler, nodes, errMsg);
	}
	else
	{
		errMsg += "stash is empty";
	}

	return  success;
}
开发者ID:3drepo,项目名称:3drepobouncer,代码行数:32,代码来源:repo_scene.cpp

示例4: makeMetaDataNode

MetadataNode RepoBSONFactory::makeMetaDataNode(
	RepoBSON			          &metadata,
	const std::string             &mimeType,
	const std::string             &name,
	const std::vector<repoUUID>  &parents,
	const int                     &apiLevel)
{
	RepoBSONBuilder builder;

	// Compulsory fields such as _id, type, api as well as path
	// and optional name
	auto defaults = appendDefaults(REPO_NODE_TYPE_METADATA, apiLevel, generateUUID(), name, parents);
	builder.appendElements(defaults);

	//--------------------------------------------------------------------------
	// Media type
	if (!mimeType.empty())
		builder << REPO_LABEL_MEDIA_TYPE << mimeType;

	//--------------------------------------------------------------------------
	// Add metadata subobject
	if (!metadata.isEmpty())
		builder << REPO_NODE_LABEL_METADATA << metadata;

	return MetadataNode(builder.obj());
}
开发者ID:3drepo,项目名称:3drepobouncer,代码行数:26,代码来源:repo_bson_factory.cpp

示例5: makeRepoProjectSettings

RepoProjectSettings RepoBSONFactory::makeRepoProjectSettings(
	const std::string &uniqueProjectName,
	const std::string &owner,
	const std::string &type,
	const std::string &description,
	const double pinSize,
	const double avatarHeight,
	const double visibilityLimit,
	const double speed,
	const double zNear,
	const double zFar)
{
	RepoBSONBuilder builder;

	//--------------------------------------------------------------------------
	// Project name
	if (!uniqueProjectName.empty())
		builder << REPO_LABEL_ID << uniqueProjectName;

	//--------------------------------------------------------------------------
	// Owner
	if (!owner.empty())
		builder << REPO_LABEL_OWNER << owner;

	//--------------------------------------------------------------------------
	// Description
	if (!description.empty())
		builder << REPO_LABEL_DESCRIPTION << description;

	//--------------------------------------------------------------------------
	// Type
	if (!type.empty())
		builder << REPO_LABEL_TYPE << type;

	//--------------------------------------------------------------------------
	// Properties (embedded sub-bson)
	RepoBSONBuilder propertiesBuilder;
	if (pinSize != REPO_DEFAULT_PROJECT_PIN_SIZE)
		propertiesBuilder << REPO_LABEL_PIN_SIZE << pinSize;
	if (avatarHeight != REPO_DEFAULT_PROJECT_AVATAR_HEIGHT)
		propertiesBuilder << REPO_LABEL_AVATAR_HEIGHT << avatarHeight;
	if (visibilityLimit != REPO_DEFAULT_PROJECT_VISIBILITY_LIMIT)
		propertiesBuilder << REPO_LABEL_VISIBILITY_LIMIT << visibilityLimit;
	if (speed != REPO_DEFAULT_PROJECT_SPEED)
		propertiesBuilder << REPO_LABEL_SPEED << speed;
	if (zNear != REPO_DEFAULT_PROJECT_ZNEAR)
		propertiesBuilder << REPO_LABEL_ZNEAR << zNear;
	if (zFar != REPO_DEFAULT_PROJECT_ZFAR)
		propertiesBuilder << REPO_LABEL_ZFAR << zFar;
	RepoBSON propertiesBSON = propertiesBuilder.obj();
	if (propertiesBSON.isValid() && !propertiesBSON.isEmpty())
		builder << REPO_LABEL_PROPERTIES << propertiesBSON;

	//--------------------------------------------------------------------------
	// Add to the parent object
	return RepoProjectSettings(builder.obj());
}
开发者ID:3drepo,项目名称:3drepobouncer,代码行数:57,代码来源:repo_bson_factory.cpp

示例6: appendDefaults

TransformationNode RepoBSONFactory::makeTransformationNode(
	const std::vector<std::vector<float>> &transMatrix,
	const std::string                     &name,
	const std::vector<repoUUID>		  &parents,
	const int                             &apiLevel)
{
	RepoBSONBuilder builder;

	auto defaults = appendDefaults(REPO_NODE_TYPE_TRANSFORMATION, apiLevel, generateUUID(), name, parents);
	builder.appendElements(defaults);

	//--------------------------------------------------------------------------
	// Store matrix as array of arrays
	uint32_t matrixSize = 4;
	RepoBSONBuilder rows;
	for (uint32_t i = 0; i < transMatrix.size(); ++i)
	{
		RepoBSONBuilder columns;
		for (uint32_t j = 0; j < transMatrix[i].size(); ++j){
			columns << std::to_string(j) << transMatrix[i][j];
		}
		rows.appendArray(std::to_string(i), columns.obj());
	}
	builder.appendArray(REPO_NODE_LABEL_MATRIX, rows.obj());

	return TransformationNode(builder.obj());
}
开发者ID:3drepo,项目名称:3drepobouncer,代码行数:27,代码来源:repo_bson_factory.cpp

示例7: updateRevisionStatus

bool RepoScene::commitStash(
	repo::core::handler::AbstractDatabaseHandler *handler,
	std::string &errMsg)
{
	/*
	* Don't bother if:
	* 1. root node is null (not instantiated)
	* 2. revnode is null (unoptimised scene graph needs to be commited first
	*/

	repoUUID rev;
	if (!handler)
	{
		errMsg += "Cannot commit stash graph - nullptr to database handler.";
		return false;
	}
	if (!revNode)
	{
		errMsg += "Revision node not found, make sure the default scene graph is commited";
		return false;
	}
	else
	{
		rev = revNode->getUniqueID();
	}
	if (stashGraph.rootNode)
	{
		updateRevisionStatus(handler, repo::core::model::RevisionNode::UploadStatus::GEN_REPO_STASH);
		//Add rev id onto the stash nodes before committing.
		std::vector<repoUUID> nodes;
		RepoBSONBuilder builder;
		builder.append(REPO_NODE_STASH_REF, rev);
		RepoBSON revID = builder.obj(); // this should be RepoBSON?

		for (auto &pair : stashGraph.nodesByUniqueID)
		{
			nodes.push_back(pair.first);
			*pair.second = pair.second->cloneAndAddFields(&revID, false);
		}

		auto success = commitNodes(handler, nodes, GraphType::OPTIMIZED, errMsg);

		if (success)
			updateRevisionStatus(handler, repo::core::model::RevisionNode::UploadStatus::COMPLETE);

		return success;
	}
	else
	{
		//Not neccessarily an error. Make it visible for debugging purposes
		repoDebug << "Stash graph not commited. Root node is nullptr!";
		return true;
	}
}
开发者ID:3drepo,项目名称:3drepobouncer,代码行数:54,代码来源:repo_scene.cpp

示例8: BSON

RepoRole RepoBSONFactory::_makeRepoRole(
	const std::string &roleName,
	const std::string &database,
	const std::vector<RepoPrivilege> &privileges,
	const std::vector<std::pair<std::string, std::string> > &inheritedRoles
	)
{
	RepoBSONBuilder builder;
	builder << REPO_LABEL_ID << database + "." + roleName;
	builder << REPO_ROLE_LABEL_ROLE << roleName;
	builder << REPO_ROLE_LABEL_DATABASE << database;

	//====== Add Privileges ========
	if (privileges.size() > 0)
	{
		RepoBSONBuilder privilegesBuilder;
		for (size_t i = 0; i < privileges.size(); ++i)
		{
			const auto &p = privileges[i];
			RepoBSONBuilder innerBsonBuilder, actionBuilder;
			RepoBSON resource = BSON(REPO_ROLE_LABEL_DATABASE << p.database << REPO_ROLE_LABEL_COLLECTION << p.collection);
			innerBsonBuilder << REPO_ROLE_LABEL_RESOURCE << resource;

			for (size_t aCount = 0; aCount < p.actions.size(); ++aCount)
			{
				actionBuilder << std::to_string(aCount) << RepoRole::dbActionToString(p.actions[aCount]);
			}

			innerBsonBuilder.appendArray(REPO_ROLE_LABEL_ACTIONS, actionBuilder.obj());

			privilegesBuilder << std::to_string(i) << innerBsonBuilder.obj();
		}
		builder.appendArray(REPO_ROLE_LABEL_PRIVILEGES, privilegesBuilder.obj());
	}
	else
	{
		repoDebug << "Creating a role with no privileges!";
	}

	//====== Add Inherited Roles ========

	if (inheritedRoles.size() > 0)
	{
		RepoBSONBuilder inheritedRolesBuilder;

		for (size_t i = 0; i < inheritedRoles.size(); ++i)
		{
			RepoBSON parentRole = BSON(
				REPO_ROLE_LABEL_ROLE << inheritedRoles[i].second
				<< REPO_ROLE_LABEL_DATABASE << inheritedRoles[i].first
				);

			inheritedRolesBuilder << std::to_string(i) << parentRole;
		}

		builder.appendArray(REPO_ROLE_LABEL_INHERITED_ROLES, inheritedRolesBuilder.obj());
	}

	return RepoRole(builder.obj());
}
开发者ID:3drepo,项目名称:3drepobouncer,代码行数:60,代码来源:repo_bson_factory.cpp

示例9: makeTransformationNode

TransformationNode RepoBSONFactory::makeTransformationNode(
	const repo::lib::RepoMatrix &transMatrix,
	const std::string                     &name,
	const std::vector<repo::lib::RepoUUID>		  &parents,
	const int                             &apiLevel)
{
	RepoBSONBuilder builder;

	auto defaults = appendDefaults(REPO_NODE_TYPE_TRANSFORMATION, apiLevel, repo::lib::RepoUUID::createUUID(), name, parents);
	builder.appendElements(defaults);

	builder.append(REPO_NODE_LABEL_MATRIX, transMatrix);	

	return TransformationNode(builder.obj());
}
开发者ID:kagula,项目名称:3drepobouncer,代码行数:15,代码来源:repo_bson_factory.cpp

示例10: cloneAndAddFields

RepoNode RepoNode::cloneAndAddFields(
	const RepoBSON *changes,
	const bool     &newUniqueID) const
{
	RepoBSONBuilder builder;
	if (newUniqueID)
	{
		builder.append(REPO_NODE_LABEL_ID, generateUUID());
	}

	builder.appendElementsUnique(*changes);

	builder.appendElementsUnique(*this);

	return RepoNode(builder.obj(), bigFiles);
}
开发者ID:3drepo,项目名称:3drepobouncer,代码行数:16,代码来源:repo_node.cpp

示例11: makeTextureNode

TextureNode RepoBSONFactory::makeTextureNode(
	const std::string &name,
	const char        *data,
	const uint32_t    &byteCount,
	const uint32_t    &width,
	const uint32_t    &height,
	const int         &apiLevel)
{
	RepoBSONBuilder builder;
	auto defaults = appendDefaults(REPO_NODE_TYPE_TEXTURE, apiLevel, generateUUID(), name);
	builder.appendElements(defaults);
	//
	// Width
	//
	builder << REPO_LABEL_WIDTH << width;

	//
	// Height
	//
	builder << REPO_LABEL_HEIGHT << height;

	//
	// Format TODO: replace format with MIME Type?
	//
	if (!name.empty())
	{
		boost::filesystem::path file{ name };
		std::string ext = file.extension().string();
		if (!ext.empty())
			builder << REPO_NODE_LABEL_EXTENSION << ext.substr(1, ext.size());
	}
	//
	// Data
	//

	if (data && byteCount)
		builder.appendBinary(
		REPO_LABEL_DATA,
		data,
		byteCount);
	else
	{
		repoWarning << " Creating a texture node with no texture!";
	}

	return TextureNode(builder.obj());
}
开发者ID:3drepo,项目名称:3drepobouncer,代码行数:47,代码来源:repo_bson_factory.cpp

示例12: cloneAndAddParent

RepoNode RepoNode::cloneAndAddParent(
	const std::vector<repoUUID> &parentIDs) const
{
	RepoBSONBuilder builder;
	RepoBSONBuilder arrayBuilder;

	std::vector<repoUUID> currentParents = getParentIDs();
	currentParents.insert(currentParents.end(), parentIDs.begin(), parentIDs.end());

	std::sort(currentParents.begin(), currentParents.end());
	auto last = std::unique(currentParents.begin(), currentParents.end());
	if (last != currentParents.end())
		currentParents.erase(last, currentParents.end());

	builder.appendArray(REPO_NODE_LABEL_PARENTS, currentParents);

	builder.appendElementsUnique(*this);

	return RepoNode(builder.obj(), bigFiles);
}
开发者ID:3drepo,项目名称:3drepobouncer,代码行数:20,代码来源:repo_node.cpp

示例13: cloneAndApplyTransformation

RepoNode CameraNode::cloneAndApplyTransformation(
	const std::vector<float> &matrix) const
{
	RepoBSONBuilder builder;
	if (hasField(REPO_NODE_LABEL_LOOK_AT))
	{
		builder.append(REPO_NODE_LABEL_LOOK_AT, multiplyMatVec(matrix, getLookAt()));
	}

	if (hasField(REPO_NODE_LABEL_POSITION))
	{
		builder.append(REPO_NODE_LABEL_POSITION, multiplyMatVec(matrix, getPosition()));
	}

	if (hasField(REPO_NODE_LABEL_UP))
	{
		builder.append(REPO_NODE_LABEL_UP, multiplyMatVec(matrix, getUp()));
	}
	return CameraNode(builder.appendElementsUnique(*this));
}
开发者ID:wsdflink,项目名称:3drepobouncer,代码行数:20,代码来源:repo_node_camera.cpp

示例14: cloneAndRemoveParent

RepoNode RepoNode::cloneAndRemoveParent(
	const repoUUID &parentID,
	const bool     &newUniqueID) const
{
	RepoBSONBuilder builder;
	RepoBSONBuilder arrayBuilder;

	std::vector<repoUUID> currentParents = getParentIDs();
	auto parentIdx = std::find(currentParents.begin(), currentParents.end(), parentID);
	if (parentIdx != currentParents.end())
	{
		currentParents.erase(parentIdx);
		if (newUniqueID)
		{
			builder.append(REPO_NODE_LABEL_ID, generateUUID());
		}
	}
	else
	{
		repoWarning << "Trying to remove a parent that isn't really a parent!";
	}
	if (currentParents.size() > 0)
	{
		builder.appendArray(REPO_NODE_LABEL_PARENTS, currentParents);
		builder.appendElementsUnique(*this);
	}
	else
	{
		builder.appendElementsUnique(removeField(REPO_NODE_LABEL_PARENTS));
	}

	return RepoNode(builder.obj(), bigFiles);
}
开发者ID:3drepo,项目名称:3drepobouncer,代码行数:33,代码来源:repo_node.cpp

示例15: loadRevision

bool RepoScene::loadRevision(
	repo::core::handler::AbstractDatabaseHandler *handler,
	std::string &errMsg){
	bool success = true;

	if (!handler)
	{
		errMsg = "Cannot load revision with an empty database handler";
		return false;
	}

	RepoBSON bson;
	repoTrace << "loading revision : " << databaseName << "." << projectName << " head Revision: " << headRevision;
	if (headRevision){
		RepoBSONBuilder critBuilder;
		critBuilder.append(REPO_NODE_LABEL_SHARED_ID, branch);
		critBuilder << REPO_NODE_REVISION_LABEL_INCOMPLETE << BSON("$exists" << false);

		bson = handler->findOneByCriteria(databaseName, projectName + "." +
			revExt, critBuilder.obj(), REPO_NODE_REVISION_LABEL_TIMESTAMP);
		repoTrace << "Fetching head of revision from branch " << UUIDtoString(branch);
	}
	else{
		bson = handler->findOneByUniqueID(databaseName, projectName + "." + revExt, revision);
		repoTrace << "Fetching revision using unique ID: " << UUIDtoString(revision);
	}

	if (bson.isEmpty()){
		errMsg = "Failed: cannot find revision document from " + databaseName + "." + projectName + "." + revExt;
		success = false;
	}
	else{
		revNode = new RevisionNode(bson);
		worldOffset = revNode->getCoordOffset();
	}

	return success;
}
开发者ID:3drepo,项目名称:3drepobouncer,代码行数:38,代码来源:repo_scene.cpp


注:本文中的RepoBSONBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。