printable_object.cpp
Go to the documentation of this file.
00001 /*
00002  *    This file is part of CasADi.
00003  *
00004  *    CasADi -- A symbolic framework for dynamic optimization.
00005  *    Copyright (C) 2010 by Joel Andersson, Moritz Diehl, K.U.Leuven. All rights reserved.
00006  *
00007  *    CasADi is free software; you can redistribute it and/or
00008  *    modify it under the terms of the GNU Lesser General Public
00009  *    License as published by the Free Software Foundation; either
00010  *    version 3 of the License, or (at your option) any later version.
00011  *
00012  *    CasADi is distributed in the hope that it will be useful,
00013  *    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  *    Lesser General Public License for more details.
00016  *
00017  *    You should have received a copy of the GNU Lesser General Public
00018  *    License along with CasADi; if not, write to the Free Software
00019  *    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00020  *
00021  */
00022 
00023 #include "printable_object.hpp"
00024 #include <typeinfo>
00025 #include <sstream>
00026 
00027 
00028 using namespace std;
00029 namespace CasADi{
00030 
00031 ostream& operator<<(ostream &stream, const PrintableObject& obj){
00032   obj.repr(stream);
00033   return stream;
00034 }
00035 
00036 void PrintableObject::repr(std::ostream &stream) const{
00037   // Print description by default
00038   print(stream);
00039 }
00040 
00041 void PrintableObject::print(std::ostream &stream) const{
00042   // Print name by default
00043   stream << typeid(this).name();
00044 }
00045 
00046 string PrintableObject::getRepresentation() const{
00047   stringstream ss;
00048   repr(ss);
00049   return ss.str();
00050 }
00051 
00052 string PrintableObject::getDescription() const{
00053   stringstream ss;
00054   print(ss);
00055   return ss.str();  
00056 }
00057 
00058     
00059 } // namespace CasADi
00060     
00061 
00062 


acado
Author(s): Milan Vukov, Rien Quirynen
autogenerated on Thu Aug 27 2015 11:59:49