MOOS 0.2375
/home/toby/moos-ivp/MOOS-2375-Oct0611/NavigationAndControl/MOOSNavLib/MOOSNavBase.cpp
Go to the documentation of this file.
00001 
00002 //
00003 //   MOOS - Mission Oriented Operating Suite
00004 //
00005 //   A suit of Applications and Libraries for Mobile Robotics Research
00006 //   Copyright (C) 2001-2005 Massachusetts Institute of Technology and
00007 //   Oxford University.
00008 //
00009 //   This software was written by Paul Newman and others
00010 //   at MIT 2001-2002 and Oxford University 2003-2005.
00011 //   email: pnewman@robots.ox.ac.uk.
00012 //
00013 //   This file is part of a  MOOS Basic (Common) Application.
00014 //
00015 //   This program is free software; you can redistribute it and/or
00016 //   modify it under the terms of the GNU General Public License as
00017 //   published by the Free Software Foundation; either version 2 of the
00018 //   License, or (at your option) any later version.
00019 //
00020 //   This program is distributed in the hope that it will be useful,
00021 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
00022 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00023 //   General Public License for more details.
00024 //
00025 //   You should have received a copy of the GNU General Public License
00026 //   along with this program; if not, write to the Free Software
00027 //   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00028 //   02111-1307, USA.
00029 //
00031 // MOOSNavBase.cpp: implementation of the CMOOSNavBase class.
00032 //
00034 
00035 
00036 #include <stdarg.h>
00037 #include "MOOSNavBase.h"
00038 #include <typeinfo>
00039 #include <cstring>
00040 
00042 // Construction/Destruction
00044 
00045 CMOOSNavBase::CMOOSNavBase()
00046 {
00047     m_pOutputList = NULL;
00048 }
00049 
00050 CMOOSNavBase::~CMOOSNavBase()
00051 {
00052 
00053 }
00054 
00055 void CMOOSNavBase::Trace()
00056 {
00057     MOOSTrace("%s id(%d) type %s\n",m_sName.c_str(),m_nID,GetTypeName().c_str());
00058 }
00059 
00060 string CMOOSNavBase::GetTypeName()
00061 {
00062     return typeid(*this).name();
00063 }
00064 
00065 string CMOOSNavBase::GetName()
00066 {
00067     return m_sName;
00068 }
00069 
00070 int CMOOSNavBase::GetID()
00071 {
00072     return m_nID;
00073 }
00074 
00075 bool CMOOSNavBase::AddToOutput(string  sStr)
00076 {
00077     return AddToOutput("%s",sStr.c_str());
00078 }
00079 bool CMOOSNavBase::AddToOutput(const char *FmtStr,...)
00080 {
00081 
00082     const int MAX_TRACE_STR = 1024;
00083 
00084     if(strlen(FmtStr)<MAX_TRACE_STR)
00085     {
00086         //double the size for format length!
00087         char buf[MAX_TRACE_STR*2];
00088 
00089         va_list arg_ptr;
00090 
00091         va_start( arg_ptr,FmtStr);
00092 
00093         vsprintf(buf,FmtStr,arg_ptr);
00094 
00095         va_end( arg_ptr );
00096 
00097 
00098         string sText = string(buf);
00099 
00100         if(m_pOutputList!=NULL)
00101         {
00102             CMOOSMsg Msg(MOOS_NOTIFY,"MOOS_DEBUG",sText.c_str());
00103             m_pOutputList->push_front(Msg);
00104         }
00105 
00106         MOOSTrace(sText+"\n");
00107 
00108 
00109     }
00110     else
00111     {
00112         return false;
00113     }
00114 
00115     return true;
00116 }
00117 
00118 
00119 bool CMOOSNavBase::SetOutputList(MOOSMSG_LIST *pList)
00120 {
00121     m_pOutputList = pList;
00122     return m_pOutputList!=NULL;
00123 }
00124 
00125 bool CMOOSNavBase::SetName(string sName)
00126 {
00127     m_sName = sName;
00128     return true;
00129 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines