MOOS 0.2375
/home/toby/moos-ivp/MOOS-2375-Oct0611/Essentials/MOOSUtilityLib/ThirdPartyRequest.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 at MIT 2001-2002 and Oxford 
00010 //   University 2003-2005. email: pnewman@robots.ox.ac.uk. 
00011 //      
00012 //   This file is part of a  MOOS Core Component. 
00013 //        
00014 //   This program is free software; you can redistribute it and/or 
00015 //   modify it under the terms of the GNU General Public License as 
00016 //   published by the Free Software Foundation; either version 2 of the 
00017 //   License, or (at your option) any later version. 
00018 //          
00019 //   This program is distributed in the hope that it will be useful, 
00020 //   but WITHOUT ANY WARRANTY; without even the implied warranty of 
00021 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
00022 //   General Public License for more details. 
00023 //            
00024 //   You should have received a copy of the GNU General Public License 
00025 //   along with this program; if not, write to the Free Software 
00026 //   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 
00027 //   02111-1307, USA. 
00028 //
00030 // ThirdPartyRequest.cpp: implementation of the CThirdPartyRequest class.
00031 //
00033 #ifdef _WIN32
00034     #pragma warning(disable : 4786)
00035 #endif
00036 
00037 #include <MOOSGenLib/MOOSGenLibGlobalHelper.h>
00038 #include "ThirdPartyRequest.h"
00039 
00040 #include <map>
00041 using namespace std;
00042 
00044 // Construction/Destruction
00046 
00047 CThirdPartyRequest::CThirdPartyRequest()
00048 {
00049     m_sDelim    = "|";
00050     m_sEq        = "=";
00051     m_sAt        = "@";
00052     m_sCol        = ":";
00053     m_sClientInfo = "JOB@CLIENT";
00054 }
00055 
00056 CThirdPartyRequest::~CThirdPartyRequest()
00057 {
00058 
00059 }
00060 
00061 void CThirdPartyRequest::MOOSThirdPartyFormat(CThirdPartyRequest &Request, string sTok, string sVal)
00062 {
00063     Request.AddProperty(sTok,sVal);
00064 
00065 }
00066 
00067 void CThirdPartyRequest::AddProperty(string sTok, string sVal)
00068 {
00069     MOOSToUpper(sTok);
00070     MOOSToUpper(sVal);
00071     
00072     if(m_Properties.find(sTok)==m_Properties.end())
00073     {
00074         STRING_LIST NewList;
00075         m_Properties[sTok] = (NewList);
00076     }
00077 
00078     m_Properties[sTok].push_back(sVal);
00079 }
00080 
00081 string CThirdPartyRequest::ExecuteRequest()
00082 {
00083     string sFormattedThirdParty;
00084 
00085     STRING_LIST_MAP::iterator p;
00086     for(p = m_Properties.begin(); p != m_Properties.end(); p++)
00087     {
00088         STRING_LIST & rList = p->second;
00089         STRING_LIST::iterator q;
00090         for(q = rList.begin();q!=rList.end();q++)
00091         {
00092             string sVal = *q;
00093             string sValuePair = p->first + m_sEq + sVal;
00094             sFormattedThirdParty += sValuePair + m_sDelim;    
00095         }
00096     }
00097 
00098     return (m_sClientInfo + m_sCol + "TASK=" + m_sTaskType + m_sDelim + sFormattedThirdParty);
00099 }
00100 
00101 bool CThirdPartyRequest::ClearProperties()
00102 {
00103     m_Properties.clear();
00104     return true;
00105 }
00106 
00107 string CThirdPartyRequest::MOOSThirdPartyExecute(CThirdPartyRequest &Request)
00108 {
00109     return Request.ExecuteRequest();
00110 }
00111 
00112 bool CThirdPartyRequest::MOOSThirdPartyClear(CThirdPartyRequest &Request)
00113 {
00114     return Request.ClearProperties();
00115 }
00116 
00117 void CThirdPartyRequest::SetClientInfo(string sJob, string sClient)
00118 {
00119     m_sClientInfo = sJob + m_sAt + sClient;
00120 }
00121 
00122 string CThirdPartyRequest::Close()
00123 {
00124     return m_sClientInfo + m_sCol + "CLOSE";
00125 }
00126 
00127 bool CThirdPartyRequest::SetTaskInfo(string sTaskType)
00128 {
00129     m_sTaskType = sTaskType;
00130     return true;
00131 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines