From: Dominic L. <ma...@us...> - 2004-06-07 15:10:20
|
Update of /cvsroot/robotflow/RobotFlow/MARIE/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1454/src Modified Files: Makefile.am MarieLoad.cpp Added Files: MarieDataNull.cpp Log Message: added MarieDataNull Index: MarieLoad.cpp =================================================================== RCS file: /cvsroot/robotflow/RobotFlow/MARIE/src/MarieLoad.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** MarieLoad.cpp 31 May 2004 14:10:09 -0000 1.2 --- MarieLoad.cpp 7 Jun 2004 15:10:11 -0000 1.3 *************** *** 44,52 **** * @output_type any * ! END*/ ! MarieLoad::MarieLoad(string nodeName, ParameterSet params) ! : BufferedNode(nodeName, params) { m_outputID = addOutput("OUTPUT"); --- 44,52 ---- * @output_type any * ! END*/ ! MarieLoad::MarieLoad(string nodeName, ParameterSet params) ! : BufferedNode(nodeName, params) { m_outputID = addOutput("OUTPUT"); *************** *** 57,123 **** { ! try { ! //default output to nilObject ! ObjectRef objValue = nilObject; ! //get input stream ! RCPtr<IOStream> input_stream = getInput(m_inputID,count); ! //instruct marie that we are gonna do a "pull" ! (*input_stream) << "<pull>"; ! //make sure we are flushing data ? ! //input_stream->flush(); ! stringstream my_stream; ! while(1) ! { ! char c; ! (*input_stream).read(&c,1); ! ! my_stream << c; ! if (my_stream.str().find("</MARIE>") != string::npos) ! { ! if (my_stream.str().find("<?xml version=\"1.0\"?><!DOCTYPE MARIE []><MARIE>NULL</MARIE>") != string::npos) { ! cerr<<"MarieLoad : Return empty object"<<endl; ! out[count] = nilObject; ! return; ! } ! else { ! break; ! } ! } ! } ! DataAbstract *data = m_factory.createData(my_stream.str()); ! if (data) { ! //create FlowDesigner type object ! objValue = Object::newObject(data->getID()); ! ! //copy data from newly created object type ! RCPtr<MarieObject> marieObjectPtr = objValue; ! ! //copy internal data ! marieObjectPtr->copyDataAbstract(data); ! ! //delete unused data ! delete data; ! } ! ! //output the newly created object ! out[count] = objValue; ! } ! catch (BaseException *e) ! { ! e->print(cerr); ! delete e; ! } ! catch (...) ! { ! cerr<<"MarieLoad : Unknown exception occured"<<endl; ! } } } --- 57,119 ---- { ! try ! { ! //default output to nilObject ! ObjectRef objValue = nilObject; ! //get input stream ! RCPtr<IOStream> input_stream = getInput(m_inputID,count); ! //instruct marie that we are gonna do a "pull" ! (*input_stream) << "<pull>"; ! //make sure we are flushing data ? ! //input_stream->flush(); ! stringstream my_stream; ! while(1) ! { ! char c; ! (*input_stream).read(&c,1); ! ! my_stream << c; ! if (my_stream.str().find("</MARIE>") != string::npos) ! { ! //found a valid MARIE object, exit loop to process it ! break; ! } ! } ! DataAbstract *data = m_factory.createData(my_stream.str()); ! if (data) ! { ! //create FlowDesigner type object ! objValue = Object::newObject(data->getID()); ! ! //copy data from newly created object type ! RCPtr<MarieObject> marieObjectPtr = objValue; ! ! //copy internal data ! marieObjectPtr->copyDataAbstract(data); ! ! //delete unused data ! delete data; ! } ! ! //output the newly created object ! out[count] = objValue; ! } ! catch (BaseException *e) ! { ! e->print(cerr); ! delete e; ! } ! catch (...) ! { ! cerr<<"MarieLoad : Unknown exception occured"<<endl; ! } } } Index: Makefile.am =================================================================== RCS file: /cvsroot/robotflow/RobotFlow/MARIE/src/Makefile.am,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Makefile.am 31 May 2004 20:15:33 -0000 1.4 --- Makefile.am 7 Jun 2004 15:10:11 -0000 1.5 *************** *** 13,16 **** --- 13,17 ---- MarieDataCamera.cpp \ MarieDataOdometry.cpp \ + MarieDataNull.cpp \ MarieCommandBehavior.cpp \ MarieCommandCamera.cpp \ --- NEW FILE: MarieDataNull.cpp --- /* * MARIE - Mobile and Autonomous Robotics Integration Environment * Copyright (C) 2004 Carle Cote * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * You can contact MARIE development team at http://marie.sourceforge.net */ #include "MarieDataNull.h" #include <sstream> #include <string> #include "MarieXMLDataFactory.h" namespace marie { DECLARE_NODE(MarieDataNull) /*Node * * @name MarieDataNull * @category RobotFlow:MARIE:DATA * @description Read content of MarieDataNull * * @input_name NULL_DATA * @input_type MarieDataNull * @input_description The Odometry object * * @output_name DATANULL * @output_description MARIE NullData object * @output_type int * END*/ using namespace std; DECLARE_TYPE2(DataNull::ID,MarieDataNull) MarieDataNull::MarieDataNull() : MarieObject("MarieDataNull",ParameterSet()), m_isNode(false) { } MarieDataNull::MarieDataNull (const DataNull &data) : MarieObject("MarieDataNull",ParameterSet()), DataNull(data), m_isNode(false) { } MarieDataNull::MarieDataNull(string nodeName, ParameterSet params) : MarieObject(nodeName,params), m_isNode(true) { //used as a BufferedNode, create inputs & outputs //output m_dataNullOutID = addOutput("DATANULL"); //create dataNullObject m_dataNullObject = ObjectRef(new MarieDataNull()); } void MarieDataNull::calculate(int output_id, int count, Buffer &out) { if (m_isNode) { out[count] = m_dataNullObject; } else { out[count] = nilObject; } } void MarieDataNull::printOn(ostream &out) const { MarieXMLDataFactory factory; //writing XML data string value = factory.toString((DataNull&) (*this)); out.write(value.c_str(), value.size()); } void MarieDataNull::readFrom(istream &in) { throw new GeneralException("readFrom not supported. Use the MarieLoad Node to read data from the stream.",__FILE__,__LINE__); } void MarieDataNull::copyDataAbstract(DataAbstract *data) { if (data) { DataNull *my_data = dynamic_cast<DataNull*>(data); if (my_data) { //((DataNull*)this)->operator=(*my_data); this->DataNull::operator=(*my_data); } else { throw new GeneralException(string("Unable to cast into DataNull Abstract : ") + data->getID(),__FILE__,__LINE__); } } } } |