Object.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2009 by Ulrich Friedrich Klank <klank@in.tum.de>
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 3 of the License, or
00007  * (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00016  */
00017 
00018 
00019 /************************************************************************
00020                         Object.cpp - Copyright klank
00021 
00022 
00023 **************************************************************************/
00024 
00025 #include "Object.h"
00026 #include "XMLTag.h"
00027 // Constructors/Destructors
00028 //
00029 using namespace cop;
00030 
00031 Object::Object ( ) :
00032   m_relPose(NULL),
00033   m_bCommunicationCallBack(false)
00034 {
00035 }
00036 
00037 void Object::SetData(XMLTag* tag )
00038 {
00039   Elem::SetData(tag);
00040   m_relPose = NULL; /*RelPoseFactory::FRelPose(tag->GetChild(XML_NODE_RELPOSE));*/
00041   m_bCommunicationCallBack = false;
00042 }
00043 
00044 Object::~Object ( )
00045 {
00046   if(m_bCommunicationCallBack)
00047     delete m_com;
00048 }
00049 
00050 
00051 
00052 //
00053 // Methods
00054 //
00055 void Object::SetCommCallBack(Comm* com)
00056 {
00057   if(m_bCommunicationCallBack)
00058     delete m_com;
00059   m_com = NULL;
00060   if(com != NULL)
00061   {
00062     m_bCommunicationCallBack = true;
00063     m_com = com;
00064   }
00065   else
00066   {
00067      m_bCommunicationCallBack = false;
00068   }
00069 }
00070 
00071 void Object::SetPose(RelPose* pose)
00072 {
00073   if(pose != NULL)
00074   {
00075 #ifdef _DEBUG
00076     printf("Setting new pose. (%ld)\n", pose->m_uniqueID );
00077 #endif
00078     if(m_relPose != NULL && !(pose->m_uniqueID == m_relPose->m_uniqueID))
00079       RelPoseFactory::FreeRelPose(&m_relPose);
00080     m_relPose = pose;
00081     Touch();
00082   }
00083   if(m_bCommunicationCallBack)
00084   {
00085 #ifdef _DEBUG
00086     printf("Sending update Notification.\n");
00087 #endif
00088     m_com->NotifyPoseUpdate(pose, true);
00089   }
00090 }
00091 
00092 
00093 // Accessor methods
00094 //
00095 void Object::SaveTo(XMLTag* tag)
00096 {
00097   if(m_relPose != NULL)
00098   {
00099     if(!m_fullPose)
00100       tag->AddChild(m_relPose->Save());
00101     else
00102       tag->AddChild(m_relPose->SaveComplete());
00103   }
00104 }
00105 
00106 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines


cognitive_perception
Author(s): Ulrich F Klank
autogenerated on Thu May 23 2013 07:38:34