OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-atomspace commits / 0dde84e

Provide a LiteralValueOfLink implementation
0dde84e03c38c698cb385011ebbc6cd17af61abf
by Linas Vepštas <linasvepstas@gmail.com> · 2026-01-22T20:21:34.000Z

Changed files (2) +63 -0

opencog/atoms/flow/CMakeLists.txt +2 -0
……@@ -13,6 +13,7 @@ ADD_LIBRARY (atomflow
1313 JsonSplitLink.cc
1414 KeysOfLink.cc
1515 LinkSignatureLink.cc
16 LiteralValueOfLink.cc
1617 MessagesOfLink.cc
1718 SetValueLink.cc
1819 SizeOfLink.cc
……@@ -48,6 +49,7 @@ INSTALL (FILES
4849 JsonSplitLink.h
4950 KeysOfLink.h
5051 LinkSignatureLink.h
52 LiteralValueOfLink.h
5153 MessagesOfLink.h
5254 SetValueLink.h
5355 SizeOfLink.h
opencog/atoms/flow/LiteralValueOfLink.cc +61 -0
……@@ -0,0 +1,61 @@
1/*
2 * LiteralValueOfLink.cc
3 *
4 * Copyright (C) 2015, 2018 Linas Vepstas
5 *
6 * Author: Linas Vepstas <linasvepstas@gmail.com> January 2009
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU Affero General Public License v3 as
10 * published by the Free Software Foundation and including the
11 * exceptions at http://opencog.org/wiki/Licenses
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU Affero General Public
19 * License along with this program; if not, write to:
20 * Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 */
23
24#include <opencog/atomspace/AtomSpace.h>
25#include "LiteralValueOfLink.h"
26
27using namespace opencog;
28
29LiteralValueOfLink::LiteralValueOfLink(const HandleSeq&& oset, Type t)
30 : ValueOfLink(std::move(oset), t)
31{
32 if (not nameserver().isA(t, LITERAL_VALUE_OF_LINK))
33 {
34 const std::string& tname = nameserver().getTypeName(t);
35 throw InvalidParamException(TRACE_INFO,
36 "Expecting an LiteralValueOfLink, got %s", tname.c_str());
37 }
38}
39
40// ---------------------------------------------------------------
41
42/// When executed, this will return the value at the indicated key.
43ValuePtr LiteralValueOfLink::execute(AtomSpace* as, bool silent)
44{
45 ValuePtr pap(get_literal(as, silent));
46 if (pap) return pap;
47
48 // Oh no! Nothing was found!
49 if (silent)
50 throw SilentException();
51
52 throw InvalidParamException(TRACE_INFO,
53 "No value at key %s on atom %s",
54 ak->to_string().c_str(), ah->to_string().c_str());
55
56 return createVoidValue();
57}
58
59DEFINE_LINK_FACTORY(LiteralValueOfLink, LITERAL_VALUE_OF_LINK)
60
61/* ===================== END OF FILE ===================== */