<commit_before>/**
 *  Copyright (C) 2014 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/>.
 */

#ifndef REPO_NODE_ABSTRACT_H
#define REPO_NODE_ABSTRACT_H

//------------------------------------------------------------------------------
#include <mongo/client/dbclient.h> // the MongoDB driver
//------------------------------------------------------------------------------
#include <boost/uuid/uuid.hpp> 
#include <boost/uuid/uuid_generators.hpp>
#include <boost/functional/hash.hpp>
//------------------------------------------------------------------------------
#include "../conversion/repo_transcoder_bson.h"
#include "../conversion/repo_transcoder_string.h"
//------------------------------------------------------------------------------

#include "repo_node_types.h"
#include "../repocoreglobal.h"

namespace repo {
namespace core {

//! Base abstract class for all entries stored in 3D Repo.
/*!
 * Each document preserved in 3D Repo being it a scene graph node or a revision
 * is expected to carry '_id', 'shared_id', 'paths', 'type' and 'api' 
 * information to uniquely identify the document, its type and the level of API 
 * required to decode it. Name of this object is optional information which
 * might or might not be present. It is assumed a graph may have only one root.
 */
class REPO_CORE_EXPORT RepoNodeAbstract
{

public :

    //--------------------------------------------------------------------------
	//
	// Constructors
	//
    //--------------------------------------------------------------------------

	//! Default repository document constructor.
	/*!
	 * Each object stored in the database is expected to specify '_id',
	 * 'shared_id', 'type' and 'api' properties. 
	 * 
	 * \param type repository object type such as 'material', 'mesh', etc.
	 * \param api API level of this object, information used to decode it in 
     *        clients
     * \param uuid unique identifier, randomly generated if not given
	 * \param name optional name of this object, empty string if not specified,
	 *             does not have to be unique
	 * \sa RepoNodeAbstract() and ~RepoNodeAbstract()
	 */
    // TODO: fix the shared ID so that it is not based on name any more.
	inline RepoNodeAbstract(
		const std::string &type,
		const unsigned int api = REPO_NODE_API_LEVEL_0,
		const boost::uuids::uuid &sharedId = boost::uuids::random_generator()(),
		const std::string &name = std::string()) : 
			type(type), 
			api(api), 
            sharedID(boost::uuids::random_generator()()),
			uniqueID(boost::uuids::random_generator()()), 
            name(name) {}

	//! BSON to repository node conversion constructor.
	/*!
	 * Takes a BSONObj representation loaded from the database and creates 
	 * node object with specified uuid. If type is not present, it is set to
	 * "unknown". If API level is not present, it is set to 0.
	 * 
	 * \param obj BSON representation of a scene graph or revision graph node.
	 * \sa RepoNodeAbstract() and ~RepoNodeAbstract()
	 */
	RepoNodeAbstract(const mongo::BSONObj &obj);

    //--------------------------------------------------------------------------
	//
	// Destructor
	//
    //--------------------------------------------------------------------------
<commit_msg>Fixed master branch shared ID bug.<commit_after>/**
 *  Copyright (C) 2014 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/>.
 */

#ifndef REPO_NODE_ABSTRACT_H
#define REPO_NODE_ABSTRACT_H

//------------------------------------------------------------------------------
#include <mongo/client/dbclient.h> // the MongoDB driver
//------------------------------------------------------------------------------
#include <boost/uuid/uuid.hpp> 
#include <boost/uuid/uuid_generators.hpp>
#include <boost/functional/hash.hpp>
//------------------------------------------------------------------------------
#include "../conversion/repo_transcoder_bson.h"
#include "../conversion/repo_transcoder_string.h"
//------------------------------------------------------------------------------

#include "repo_node_types.h"
#include "../repocoreglobal.h"

namespace repo {
namespace core {

//! Base abstract class for all entries stored in 3D Repo.
/*!
 * Each document preserved in 3D Repo being it a scene graph node or a revision
 * is expected to carry '_id', 'shared_id', 'paths', 'type' and 'api' 
 * information to uniquely identify the document, its type and the level of API 
 * required to decode it. Name of this object is optional information which
 * might or might not be present. It is assumed a graph may have only one root.
 */
class REPO_CORE_EXPORT RepoNodeAbstract
{

public :

    //--------------------------------------------------------------------------
	//
	// Constructors
	//
    //--------------------------------------------------------------------------

	//! Default repository document constructor.
	/*!
	 * Each object stored in the database is expected to specify '_id',
	 * 'shared_id', 'type' and 'api' properties. 
	 * 
	 * \param type repository object type such as 'material', 'mesh', etc.
	 * \param api API level of this object, information used to decode it in 
     *        clients
     * \param uuid unique identifier, randomly generated if not given
	 * \param name optional name of this object, empty string if not specified,
	 *             does not have to be unique
	 * \sa RepoNodeAbstract() and ~RepoNodeAbstract()
	 */
    // TODO: fix the shared ID so that it is not based on name any more.
	inline RepoNodeAbstract(
		const std::string &type,
		const unsigned int api = REPO_NODE_API_LEVEL_0,
		const boost::uuids::uuid &sharedId = boost::uuids::random_generator()(),
		const std::string &name = std::string()) : 
			type(type), 
			api(api), 
            sharedID(sharedId),
			uniqueID(boost::uuids::random_generator()()), 
            name(name) {}

	//! BSON to repository node conversion constructor.
	/*!
	 * Takes a BSONObj representation loaded from the database and creates 
	 * node object with specified uuid. If type is not present, it is set to
	 * "unknown". If API level is not present, it is set to 0.
	 * 
	 * \param obj BSON representation of a scene graph or revision graph node.
	 * \sa RepoNodeAbstract() and ~RepoNodeAbstract()
	 */
	RepoNodeAbstract(const mongo::BSONObj &obj);

    //--------------------------------------------------------------------------
	//
	// Destructor
	//
    //--------------------------------------------------------------------------

{'fraction_non_alphanumeric': 0.23867303472311863, 'fraction_numerical': 0.00258164450755131, 'mean_word_length': 1.8308366824990865, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '6588761', 'n_tokens_mistral': 1973, 'n_tokens_neox': 1870, 'n_words': 789}