<commit_before>#pragma once

#include <boost/noncopyable.hpp>
#include <boost/signals2.hpp>

#include <QWidget>

#include "factory.inl"
#include "node.inl"
#include "port.inl"

namespace properties {

class property_base : public boost::noncopyable {
	public:
		enum {
			kInput = 1,
			kOutput = 2,
			kDisabled = 4,
			kDirty = 8
		};

		virtual ~property_base() = 0;

		virtual QWidget* widget() = 0;

		unsigned flags() const;
		void setFlags(unsigned flags);

		/// called when the UI value is changed by the user
		boost::signals2::connection valueCallback(std::function<void()> fn);

		/// transfer the typed value to a port
		virtual void valueToPort(dependency_graph::Port& port) const = 0;
		/// transfer the typed value from a port
		virtual void valueFromPort(dependency_graph::Port& port) = 0;

	protected:
		/// can be reimplemented to change the UI's properties based on flag changes
		virtual void onFlagsChanged(unsigned flags);

		/// a callback to be connected to widget's "onChange" signal
		void callValueChangedCallbacks();

	private:
		unsigned m_flags;
		boost::signals2::signal<void()> m_valueChanged;
};

template<typename T, typename DERIVED>
class property : public property_base {
	public:
		typedef T result_type;
		typedef DERIVED derived_type;

		virtual ~property() {
			// make sure the factory is not optimized away
			static factory_typed<DERIVED>* dummy;
			dummy = &s_pf;
			dummy->type();
		}

		virtual T get() const = 0;
		virtual void set(const T& value) = 0;

	private:
		virtual void valueToPort(dependency_graph::Port& port) const override {
			// transfer the templated value
			port.set(get());
		}

		void valueFromPort(dependency_graph::Port& port) override {
			// transfer the templated value
			set(port.get<T>());<commit_msg>Property - only call set() if the port is an input<commit_after>#pragma once

#include <boost/noncopyable.hpp>
#include <boost/signals2.hpp>

#include <QWidget>

#include "factory.inl"
#include "node.inl"
#include "port.inl"

namespace properties {

class property_base : public boost::noncopyable {
	public:
		enum {
			kInput = 1,
			kOutput = 2,
			kDisabled = 4,
			kDirty = 8
		};

		virtual ~property_base() = 0;

		virtual QWidget* widget() = 0;

		unsigned flags() const;
		void setFlags(unsigned flags);

		/// called when the UI value is changed by the user
		boost::signals2::connection valueCallback(std::function<void()> fn);

		/// transfer the typed value to a port
		virtual void valueToPort(dependency_graph::Port& port) const = 0;
		/// transfer the typed value from a port
		virtual void valueFromPort(dependency_graph::Port& port) = 0;

	protected:
		/// can be reimplemented to change the UI's properties based on flag changes
		virtual void onFlagsChanged(unsigned flags);

		/// a callback to be connected to widget's "onChange" signal
		void callValueChangedCallbacks();

	private:
		unsigned m_flags;
		boost::signals2::signal<void()> m_valueChanged;
};

template<typename T, typename DERIVED>
class property : public property_base {
	public:
		typedef T result_type;
		typedef DERIVED derived_type;

		virtual ~property() {
			// make sure the factory is not optimized away
			static factory_typed<DERIVED>* dummy;
			dummy = &s_pf;
			dummy->type();
		}

		virtual T get() const = 0;
		virtual void set(const T& value) = 0;

	private:
		virtual void valueToPort(dependency_graph::Port& port) const override {
			// transfer the templated value
			if((flags() & kInput) && !(flags() & kDisabled))
				port.set(get());
		}

		void valueFromPort(dependency_graph::Port& port) override {
			// transfer the templated value
			set(port.get<T>());
{'fraction_non_alphanumeric': 0.11190345584201865, 'fraction_numerical': 0.007131102578167855, 'mean_word_length': 4.016506189821183, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 21, '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': '5553839', 'n_tokens_mistral': 1299, 'n_tokens_neox': 1130, 'n_words': 366}