10 #include <opencog/util/exceptions.h>
28 throw InvalidParamException(TRACE_INFO,
29 "Invalid AtomType parameter '%s'.",type);
35 ,
const UUID* outgoing
40 throw InvalidParamException(TRACE_INFO,
41 "Invalid AtomType parameter '%s'.",type);
43 for(
int i=0;i<size;i++)
44 oset.push_back(
Handle(outgoing[i]));
55 throw InvalidParamException(TRACE_INFO,
56 "Invalid AtomType parameter '%s'.",type);
58 *found = h != Handle::UNDEFINED;
64 ,
const UUID* outgoing
70 throw InvalidParamException(TRACE_INFO,
71 "Invalid AtomType parameter '%s'.",type);
73 for(
int i=0;i<size;i++)
74 oset.push_back(
Handle(outgoing[i]));
76 *found = h != Handle::UNDEFINED;
95 throw InvalidParamException(TRACE_INFO,
96 "Invalid Handler parameter.");
99 (*type) = (
char*) malloc(
sizeof(
char) * (str.length()+1));
101 throw RuntimeException(TRACE_INFO,
"Failed malloc.");
102 std::strcpy(*type, str.c_str());
106 const std::string &str = ptr->getName();
107 (*name) = (
char*) malloc(
sizeof(
char) * (str.length()+1));
109 throw RuntimeException(TRACE_INFO,
"Failed malloc.");
110 std::strcpy(*name, str.c_str());
115 throw RuntimeException(TRACE_INFO,
"Error in cast Link.");
116 *out_len=lnk->getArity();
117 (*out) = (
UUID*) malloc(
sizeof(
UUID) * (*out_len));
119 throw RuntimeException(TRACE_INFO,
"Failed malloc.");
121 for(i=0;i<(*out_len);i++)
122 (*out)[i]=lnk->getOutgoingAtom(i).value();
129 std::cerr<<(*this_ptr);
134 ,
double* parameters )
138 throw InvalidParamException(TRACE_INFO,
139 "Invalid Handler parameter.");
141 switch(tv->getType())
144 parameters[0]=tv->getMean();
145 parameters[1]=tv->getConfidence();
148 parameters[0]=tv->getMean();
149 parameters[1]=tv->getCount();
150 parameters[2]=tv->getConfidence();
156 parameters[1]=itv->getL();
157 parameters[2]=itv->getU();
158 parameters[3]=itv->getConfidenceLevel();
159 parameters[4]=itv->getDiff();
162 parameters[0]=tv->getMean();
163 parameters[1]=tv->getConfidence();
166 parameters[0]=tv->getMean();
167 parameters[1]=tv->getCount();
168 parameters[2]=tv->getConfidence();
171 throw RuntimeException(TRACE_INFO,
172 "Invalid TruthValue Type.");
175 return tv->getType();
181 ,
double* parameters )
185 throw InvalidParamException(TRACE_INFO,
186 "Invalid Handler parameter.");
190 double count = SimpleTruthValue::confidenceToCount(parameters[1]);
191 h->
setTruthValue(SimpleTruthValue::createTV(parameters[0],count));
200 IndefiniteTruthValue::createITV(parameters[1]
203 iptr->setMean(parameters[0]);
204 iptr->setDiff(parameters[4]);
205 h->
setTruthValue(std::static_pointer_cast<TruthValue>(iptr));
208 double count = FuzzyTruthValue::confidenceToCount(parameters[1]);
209 h->
setTruthValue(FuzzyTruthValue::createTV(parameters[0],count));
212 h->
setTruthValue(ProbabilisticTruthValue::createTV(parameters[0]
217 throw InvalidParamException(TRACE_INFO,
218 "Invalid TruthValue Type parameter.");
void AtomSpace_debug(AtomSpace *this_ptr)
Handle add_node(Type t, const std::string &name="", bool async=false)
int AtomSpace_removeAtom(AtomSpace *this_ptr, UUID handle)
AtomSpace * AtomSpace_new(AtomSpace *parent_ptr)
UUID AtomSpace_getLink(AtomSpace *this_ptr, const char *type, const UUID *outgoing, int size, int *found)
int AtomSpace_getAtomByHandle(AtomSpace *this_ptr, UUID handle, char **type, char **name, UUID **out, int *out_len)
std::vector< Handle > HandleSeq
a list of handles
std::shared_ptr< TruthValue > TruthValuePtr
UUID AtomSpace_getNode(AtomSpace *this_ptr, const char *type, const char *name, int *found)
std::shared_ptr< Link > LinkPtr
void setTruthValue(TruthValuePtr)
Sets the TruthValue object of the atom.
ClassServer & classserver(ClassServerFactory *=ClassServer::createInstance)
static NodePtr NodeCast(const Handle &h)
void AtomSpace_setTruthValue(AtomSpace *this_ptr, UUID handle, TruthValueType type, double *parameters)
unsigned long UUID
UUID == Universally Unique Identifier.
Handle get_node(Type t, const std::string &name="")
std::shared_ptr< IndefiniteTruthValue > IndefiniteTruthValuePtr
bool remove_atom(Handle h, bool recursive=false)
UUID AtomSpace_addLink(AtomSpace *this_ptr, const char *type, const UUID *outgoing, int size)
const std::string & getTypeName(Type type)
static LinkPtr LinkCast(const Handle &h)
UUID AtomSpace_addNode(AtomSpace *this_ptr, const char *type, const char *name)
std::shared_ptr< Node > NodePtr
Handle get_link(Type t, const HandleSeq &outgoing)
TruthValuePtr getTruthValue()
Type getType(const std::string &typeName)
unsigned short Type
type of Atoms, represented as short integer (16 bits)
Handle add_link(Type t, const HandleSeq &outgoing, bool async=false)
TruthValueType AtomSpace_getTruthValue(AtomSpace *this_ptr, UUID handle, double *parameters)
strength_t getMean() const
void AtomSpace_delete(AtomSpace *this_ptr)