<commit_before>/***************************************************************************//**
 * context.cpp
 *
 * The main root structure of cmgui.
 */
/* OpenCMISS-Zinc Library
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#if !defined (CONTEXT_H)
#define CONTEXT_H

#include <list>
#include "opencmiss/zinc/context.h"
#include "opencmiss/zinc/status.h"
#include "general/message_log.hpp"
#include "general/manager.h"

struct cmzn_graphics_module;

struct cmzn_context
{
	friend struct Element_point_ranges_selection *cmzn_context_get_element_point_ranges_selection(
		cmzn_context *context);
	friend struct IO_stream_package *cmzn_context_get_default_IO_stream_package(
		cmzn_context *context);
private:
	const char *id;
	cmzn_logger *logger;
	cmzn_region *defaultRegion;
	struct Element_point_ranges_selection *element_point_ranges_selection;
	//-- struct Event_dispatcher *event_dispatcher;
	struct IO_stream_package *io_stream_package;
	cmzn_timekeepermodule *timekeepermodule;
	std::list<cmzn_region *> allRegions; // list of all regions created for context, not accessed
	cmzn_graphics_module *graphics_module;
	int access_count;

	cmzn_context(const char *idIn);
	~cmzn_context();

public:

	inline cmzn_context *access()
	{
		++access_count;
		return this;
	}

	static inline int deaccess(cmzn_context*& context)
	{
		if (context)
		{
			--(context->access_count);
			if (context->access_count <= 0)
				delete context;
			context = 0;
			return CMZN_OK;
		}
		return CMZN_ERROR_ARGUMENT;
	}

	static cmzn_context *create(const char *id);

	cmzn_region *createRegion();

	void removeRegion(cmzn_region *region);

	cmzn_graphics_module *getGraphicsmodule()
	{
		return this->graphics_module;
	}

	/** Get any region from context from which to copy FE_region information */
	cmzn_region *getBaseRegion() const
	{
		return (this->allRegions.size() > 0) ? this->allRegions.front() : nullptr;
	}

	/** Get default region or nullptr if none */
	cmzn_region *getDefaultRegion() const
	{
		return this->defaultRegion;
	}

	/** Set default region if you wish context to manage it */
	int cmzn_context::setDefaultRegion(cmzn_region *regionIn);

	cmzn_logger *getLogger() const
	{
		return this->logger;
	}

	const std::list<cmzn_region *>& getRegionsList() const
	{
		return this->allRegions;
	}

	cmzn_timekeepermodule *getTimekeepermodule() const
	{
		return this->timekeepermodule;
	}
	
};

/***************************************************************************//**
 * Return the element point ranges selection in context.
 *
 * @param context  Pointer to a cmiss_context object.
 * @return  the Element_point_ranges_selection if successfully, otherwise NULL.
 */
struct Element_point_ranges_selection *cmzn_context_get_element_point_ranges_selection(<commit_msg>Remove class qualification from declaration setDefualtRegion.<commit_after>/***************************************************************************//**
 * context.cpp
 *
 * The main root structure of cmgui.
 */
/* OpenCMISS-Zinc Library
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#if !defined (CONTEXT_H)
#define CONTEXT_H

#include <list>
#include "opencmiss/zinc/context.h"
#include "opencmiss/zinc/status.h"
#include "general/message_log.hpp"
#include "general/manager.h"

struct cmzn_graphics_module;

struct cmzn_context
{
	friend struct Element_point_ranges_selection *cmzn_context_get_element_point_ranges_selection(
		cmzn_context *context);
	friend struct IO_stream_package *cmzn_context_get_default_IO_stream_package(
		cmzn_context *context);
private:
	const char *id;
	cmzn_logger *logger;
	cmzn_region *defaultRegion;
	struct Element_point_ranges_selection *element_point_ranges_selection;
	//-- struct Event_dispatcher *event_dispatcher;
	struct IO_stream_package *io_stream_package;
	cmzn_timekeepermodule *timekeepermodule;
	std::list<cmzn_region *> allRegions; // list of all regions created for context, not accessed
	cmzn_graphics_module *graphics_module;
	int access_count;

	cmzn_context(const char *idIn);
	~cmzn_context();

public:

	inline cmzn_context *access()
	{
		++access_count;
		return this;
	}

	static inline int deaccess(cmzn_context*& context)
	{
		if (context)
		{
			--(context->access_count);
			if (context->access_count <= 0)
				delete context;
			context = 0;
			return CMZN_OK;
		}
		return CMZN_ERROR_ARGUMENT;
	}

	static cmzn_context *create(const char *id);

	cmzn_region *createRegion();

	void removeRegion(cmzn_region *region);

	cmzn_graphics_module *getGraphicsmodule()
	{
		return this->graphics_module;
	}

	/** Get any region from context from which to copy FE_region information */
	cmzn_region *getBaseRegion() const
	{
		return (this->allRegions.size() > 0) ? this->allRegions.front() : nullptr;
	}

	/** Get default region or nullptr if none */
	cmzn_region *getDefaultRegion() const
	{
		return this->defaultRegion;
	}

	/** Set default region if you wish context to manage it */
    int setDefaultRegion(cmzn_region *regionIn);

	cmzn_logger *getLogger() const
	{
		return this->logger;
	}

	const std::list<cmzn_region *>& getRegionsList() const
	{
		return this->allRegions;
	}

	cmzn_timekeepermodule *getTimekeepermodule() const
	{
		return this->timekeepermodule;
	}
	
};

/***************************************************************************//**
 * Return the element point ranges selection in context.
 *
 * @param context  Pointer to a cmiss_context object.
 * @return  the Element_point_ranges_selection if successfully, otherwise NULL.
 */
struct Element_point_ranges_selection *cmzn_context_get_element_point_ranges_selection(
{'fraction_non_alphanumeric': 0.14479254868755292, 'fraction_numerical': 0.0023708721422523284, 'mean_word_length': 5.203781512605042, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '6414834', 'n_tokens_mistral': 1962, 'n_tokens_neox': 1853, 'n_words': 480}