Assignment.cpp
Go to the documentation of this file.
00001 /*
00002  * Assignment.h
00003  *
00004  *  Created on: Jul 28, 2011
00005  *      Author: sdries
00006  */
00007 
00008 #include "wire/logic/Assignment.h"
00009 
00010 #include "wire/storage/KnowledgeDatabase.h"
00011 #include "wire/storage/SemanticObject.h"
00012 #include "wire/storage/ObjectStorage.h"
00013 
00014 namespace mhf {
00015 
00016 Assignment::Assignment(AssignmentType type , const Evidence* evidence, const SemanticObject* target, double probability)
00017     : type_(type), evidence_(evidence), target_(target), probability_(probability), new_object_(0), updated_object_(0) {
00018 
00019 }
00020 
00021 Assignment::~Assignment() {
00022 }
00023 
00024 Assignment::AssignmentType Assignment::getType() const {
00025     return type_;
00026 }
00027 
00028 const Evidence* Assignment::getEvidence() const {
00029     return evidence_;
00030 }
00031 
00032 const SemanticObject* Assignment::getTarget() const {
00033     return target_;
00034 }
00035 
00036 double Assignment::getProbability() const {
00037     return probability_;
00038 }
00039 
00040 
00041 SemanticObject* Assignment::getNewObject() const {
00042     if (new_object_) {
00043         return new_object_;
00044     }
00045     new_object_ = new SemanticObject(ObjectStorage::getInstance().getUniqueID());
00046     new_object_->init(*evidence_);
00047 
00048     ObjectStorage::getInstance().addObject(new_object_);
00049     return new_object_;
00050 }
00051 
00052 SemanticObject* Assignment::getUpdatedObject() const {
00053     if (updated_object_) {
00054         return updated_object_;
00055     }
00056 
00057     updated_object_ = target_->clone();
00058     updated_object_->update(*evidence_);
00059 
00060     ObjectStorage::getInstance().addObject(updated_object_);
00061     return updated_object_;
00062 }
00063 
00064 std::string Assignment::toString() const {
00065     std::stringstream ss;
00066     ss << "Evidence " << evidence_ << " -> ";
00067     if (type_ == Assignment::CLUTTER) {
00068         ss << "CLUTTER";
00069     } else if (type_ == Assignment::NEW) {
00070         ss << "NEW";
00071     } else if (type_ == Assignment::EXISTING) {
00072         ss << "Object " << target_;
00073     }
00074     return ss.str();
00075 }
00076 
00077 }


wire_core
Author(s): Sjoerd van den Dries, Jos Elfring
autogenerated on Tue Jan 7 2014 11:43:19