<commit_before>/*
 * Stateplex - A server-side actor model library.
 *
 * core/method.h
 *
 * (c) 2013 <NAME> <<EMAIL>>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1 as published by the Free Software Foundation.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * Authors: <NAME>
 */

#ifndef INCLUDED_STATEPLEX_METHOD_H
#define INCLUDED_STATEPLEX_METHOD_H

class Unknown;

namespace Stateplex {

class Method {
	Unknown *mObject;
	void (Unknown::*mFunction)(Unknown *argument);
public:
	template<typename Type, typename Argument> void set(Type *object, void (Type::*function)(Argument *argument));
	template<typename Argument> void invoke(Argument *argument) const;
};

}

/*** Template implementations ***/

namespace Stateplex {

template<typename Type, typename Argument>
inline void Method::set(Type *object, void (Type::*function)(Argument *argument))
{
	mObject = reinterpret_cast<Unknown *>(object);
	mFunction = reinterpret_cast<void (Unknown::*)(Unknown *)>(function);
}

template<typename Argument>
inline void Method::invoke(Argument *argument) const
{
	(mObject->*mFunction)(reinterpret_cast<Unknown *>(argument));
}

}

#endif
<commit_msg>updated method.h<commit_after>/*
 * Stateplex - A server-side actor model library.
 *
 * core/method.h
 *
 * (c) 2013 <NAME> <<EMAIL>>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License version 2.1 as published by the Free Software Foundation.
 *
 * This library 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
 * Lesser General Public License for more details.
 *
 * Authors: <NAME>
 */

#ifndef INCLUDED_STATEPLEX_METHOD_H
#define INCLUDED_STATEPLEX_METHOD_H

class Unknown;

namespace Stateplex {

class Method {
	Unknown *mObject;
	void (Unknown::*mFunction)(Unknown *argument);
public:
	template<typename Type, typename Argument> void set(Type *object, void (Type::*function)(Argument *argument));
	template<typename Argument> void invoke(Argument *argument) const;
};

}

/*** Template implementations ***/

namespace Stateplex {

/**
 * A template fucntion that sets any pointer to be converted to any other type pointer
 *
 * @param mFunction	      is a memeber function
 */

template<typename Type, typename Argument>
inline void Method::set(Type *object, void (Type::*function)(Argument *argument))
{
	mObject = reinterpret_cast<Unknown *>(object);
	mFunction = reinterpret_cast<void (Unknown::*)(Unknown *)>(function);
}

/**
 * A template function that takes object and function and stores
 * 
 * @param *argument	    is a pointer to argument	
 */
template<typename Argument>
inline void Method::invoke(Argument *argument) const
{
	(mObject->*mFunction)(reinterpret_cast<Unknown *>(argument));
}

}

#endif

{'fraction_non_alphanumeric': 0.10699844479004665, 'fraction_numerical': 0.0037325038880248835, 'mean_word_length': 5.0, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 27, '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': '7425983', 'n_tokens_mistral': 920, 'n_tokens_neox': 896, 'n_words': 335}