[mlpack-svn] [MLPACK] #164: Standardized concept for class output to Log

MLPACK Trac trac at coffeetalk-1.cc.gatech.edu
Fri Aug 24 22:29:55 EDT 2012


#164: Standardized concept for class output to Log
------------------------------------------------------+---------------------
  Reporter:  rcurtin                                  |        Owner:  trironk3    
      Type:  wishlist                                 |       Status:  accepted    
  Priority:  major                                    |    Milestone:  mlpack 1.1.0
 Component:  mlpack                                   |   Resolution:              
  Keywords:  mlpack output model type consistent api  |     Blocking:              
Blocked By:                                           |  
------------------------------------------------------+---------------------

Comment (by trironk3):

 I've promoted some changes that allow for writing any objects with a
 ToString method to be written to one of our logging classes. Here are the
 details on how to leverage this functionality:

 Implementing a ToString method:
 The signature is as follows: std::string ToString() cost;

 Here's an example of using it in code:
 {{{
 int main()
 {
   SomeMLPACKObject test(4);
   Log::Warn << test << std::endl;
 }
 }}}

 Implementing the ToString method, itself:
 SomeMLPACKObject.hpp
 {{{
 class SomeMLPACKObject
 {
   ...
   std::string ToString() const;
   ...
 }}}

 SomeMLPACKObject.cpp
 {{{
 ...
 std::string SomeMLPACKObject::ToString() cost
 {
   std::ostringstream convert;
   convert << "SomeMLPACKObject" << this << std::endl;

   ...

   return convert.str();
 }
 ...
 }}}

-- 
Ticket URL: <http://trac.research.cc.gatech.edu/fastlab/ticket/164#comment:7>
MLPACK <www.fast-lab.org>
MLPACK is an intuitive, fast, and scalable C++ machine learning library developed by the FASTLAB at Georgia Tech under Dr. Alex Gray.


More information about the mlpack-svn mailing list