<commit_before>/**
*  Copyright (C) 2015 3D Repo Ltd
*
*  This program is free software: you can redistribute it and/or modify
*  it under the terms of the GNU Affero General Public License as
*  published by the Free Software Foundation, either version 3 of the
*  License, or (at your option) any later version.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU Affero General Public License for more details.
*
*  You should have received a copy of the GNU Affero General Public License
*  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Repo Node - A node representation of RepoBSON
*/

#pragma once 

#include "repo_bson.h"
#include "repo_bson_builder.h"
#include "../repo_node_properties.h"
#include "../repo_node_utils.h"

namespace repo{
	namespace core{
		namespace model{

				enum class NodeType{ CAMERA, MAP, MATERIAL, MESH, METADATA, REFERENCE, 
					REVISION, TEXTURE, TRANSFORMATION, UNKNOWN};

				class REPO_API_EXPORT RepoNode : public RepoBSON
				{
					public:
		
						/**
						* Constructor
						* Construct a RepoNode base on a RepoBSON object
						* 
						*/
						RepoNode(RepoBSON bson,
							const std::unordered_map<std::string, std::pair<std::string, std::vector<uint8_t>>> &binMapping =
								std::unordered_map<std::string, std::pair<std::string, std::vector<uint8_t>>>());

						/**
						* Empty Constructor
						*/
						RepoNode() : RepoBSON() {};

						/**
						* Default Deconstructor
						*/
						virtual ~RepoNode();
	
						/**
						* Check if the node is position dependant.
						* i.e. if parent transformation is merged onto the node,
						* does the node requre to a transformation applied to it
						* e.g. meshes and cameras are position dependant, metadata isn't
						* Default behaviour is false. Position dependant child requires 
						* override this function.
						* @return true if node is positionDependant.
						*/
						virtual bool positionDependant() { return false; }


						/*
						*	------------- Delusional modifiers --------------
						*   These are like "setters" but not. We are actually
						*   creating a new bson object with the changed field
						*/

						/**
						* Create a new object with this object's values,
						* and add another parent into this new object
						* NOTE: this object is unchanged!
						* @param parentID the shared uuid of the parent
						* @return new object with the field updated
						*/
						RepoNode cloneAndAddParent(
							const repoUUID &parent) const;

						/**
						* Create a new object with this object's values,
						* and add other parents into this new object
						* NOTE: this object is unchanged!
						* @param parentID the shared uuid of the parent
						* @return new object with the field updated
						*/
						RepoNode cloneAndAddParent(
							const std::vector<repoUUID> &parents) const;

						/**
						*  Create a new object with transformation applied to the node
						* default behaviour is do nothing. Children object
						* needs to override this function to perform their own specific behaviour.
						* @param matrix transformation matrix to apply.
						* @return returns a new object with transformation applied.
						*/
						virtual RepoNode cloneAndApplyTransformation(
							const std::vector<float> &matrix) const
						{
							return copy();
						}

						/**
						* Create a new object with this object's values,
						* but a different name
						* @param newName new name
						* @return returns an object with the change
						*/
						RepoNode cloneAndChangeName(
							const std::string &newName,
							const bool &newUniqueID = true
						) const
						{
							return cloneAndAddFields(new RepoBSON(BSON(REPO_NODE_LABEL_NAME << newName)), newUniqueID);
						}

						/**
						* Create a new object with this object's values,
						* and remove a parent into this new object
						* NOTE: this object is unchanged!
						* @param parentID the shared uuid of the parent
						* @param newUniqueID generate a new unique ID if set to true
						* @returns new object with the field updated
						*/
						RepoNode cloneAndRemoveParent(
							const repoUUID &parent,<commit_msg>#45 travis come on!<commit_after>/**
*  Copyright (C) 2015 3D Repo Ltd
*
*  This program is free software: you can redistribute it and/or modify
*  it under the terms of the GNU Affero General Public License as
*  published by the Free Software Foundation, either version 3 of the
*  License, or (at your option) any later version.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU Affero General Public License for more details.
*
*  You should have received a copy of the GNU Affero General Public License
*  along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
/**
* Repo Node - A node representation of RepoBSON
*/

#pragma once 

#include "repo_bson.h"
#include "repo_bson_builder.h"
#include "../repo_node_properties.h"
#include "../repo_node_utils.h"

namespace repo{
	namespace core{
		namespace model{

				enum class NodeType{ CAMERA, MAP, MATERIAL, MESH, METADATA, REFERENCE, 
					REVISION, TEXTURE, TRANSFORMATION, UNKNOWN};

				class REPO_API_EXPORT RepoNode : public RepoBSON
				{
					public:
		
						/**
						* Constructor
						* Construct a RepoNode base on a RepoBSON object
						* 
						*/
						RepoNode(RepoBSON bson,
							const std::unordered_map<std::string, std::pair<std::string, std::vector<uint8_t>>> &binMapping =
								std::unordered_map<std::string, std::pair<std::string, std::vector<uint8_t>>>());

						/**
						* Empty Constructor
						*/
						RepoNode() : RepoBSON() {};

						/**
						* Default Deconstructor
						*/
						virtual ~RepoNode();
	
						/**
						* Check if the node is position dependant.
						* i.e. if parent transformation is merged onto the node,
						* does the node requre to a transformation applied to it
						* e.g. meshes and cameras are position dependant, metadata isn't
						* Default behaviour is false. Position dependant child requires 
						* override this function.
						* @return true if node is positionDependant.
						*/
						virtual bool positionDependant() { return false; }


						/*
						*	------------- Delusional modifiers --------------
						*   These are like "setters" but not. We are actually
						*   creating a new bson object with the changed field
						*/

						/**
						* Create a new object with this object's values,
						* and add another parent into this new object
						* NOTE: this object is unchanged!
						* @param parentID the shared uuid of the parent
						* @return new object with the field updated
						*/
						RepoNode cloneAndAddParent(
							const repoUUID &parent) const;

						/**
						* Create a new object with this object's values,
						* and add other parents into this new object
						* NOTE: this object is unchanged!
						* @param parentID the shared uuid of the parent
						* @return new object with the field updated
						*/
						RepoNode cloneAndAddParent(
							const std::vector<repoUUID> &parents) const;

						/**
						*  Create a new object with transformation applied to the node
						* default behaviour is do nothing. Children object
						* needs to override this function to perform their own specific behaviour.
						* @param matrix transformation matrix to apply.
						* @return returns a new object with transformation applied.
						*/
						virtual RepoNode cloneAndApplyTransformation(
							const std::vector<float> &matrix) const
						{
							return RepoNode(copy());
						}

						/**
						* Create a new object with this object's values,
						* but a different name
						* @param newName new name
						* @return returns an object with the change
						*/
						RepoNode cloneAndChangeName(
							const std::string &newName,
							const bool &newUniqueID = true
						) const
						{
							return cloneAndAddFields(new RepoBSON(BSON(REPO_NODE_LABEL_NAME << newName)), newUniqueID);
						}

						/**
						* Create a new object with this object's values,
						* and remove a parent into this new object
						* NOTE: this object is unchanged!
						* @param parentID the shared uuid of the parent
						* @param newUniqueID generate a new unique ID if set to true
						* @returns new object with the field updated
						*/
						RepoNode cloneAndRemoveParent(
							const repoUUID &parent,
{'fraction_non_alphanumeric': 0.08365803346321339, 'fraction_numerical': 0.00206280082512033, 'mean_word_length': 2.507636655948553, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4253936', 'n_tokens_mistral': 3302, 'n_tokens_neox': 2370, 'n_words': 962}