OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-atomspace / opencog / atoms / parallel / TriggerLink.h

63 lines · c ref:
/*
 * opencog/atoms/parallel/TriggerLink.h
 *
 * Copyright (C) 2020, 2024 Linas Vepstas
 * SPDX-License-Identifier: AGPL-3.0-or-later
 * All Rights Reserved
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License v3 as
 * published by the Free Software Foundation and including the exceptions
 * at http://opencog.org/wiki/Licenses
 *
 * 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 General Public License for more details.
 */

#ifndef _OPENCOG_TRIGGER_LINK_H
#define _OPENCOG_TRIGGER_LINK_H

#include <opencog/atoms/base/Link.h>
#include <opencog/util/exceptions.h>

namespace opencog
{
/** \addtogroup grp_atomspace
 *  @{
 */

/// Custom exception thrown by TriggerLink to return the execution result.
class ValueReturnException : public SilentException
{
public:
	ValuePtr _value;
	ValueReturnException(const ValuePtr& v) : _value(v) {}
};

class TriggerLink : public Link
{
protected:
	virtual void setAtomSpace(AtomSpace *);
	virtual void install();

public:
	TriggerLink(const HandleSeq&&, Type=TRIGGER_LINK);
	TriggerLink(const TriggerLink&) = delete;
	TriggerLink& operator=(const TriggerLink&) = delete;

	virtual bool is_executable() const { return true; }
	virtual ValuePtr execute(AtomSpace*, bool);

	static Handle factory(const Handle&);
};

LINK_PTR_DECL(TriggerLink)
#define createTriggerLink CREATE_DECL(TriggerLink)

/** @}*/
}

#endif // _OPENCOG_TRIGGER_LINK_H