PLearn 0.1
PLearnDiff.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // PLearnDiff.h
00004 //
00005 // Copyright (C) 2005 Olivier Delalleau 
00006 // 
00007 // Redistribution and use in source and binary forms, with or without
00008 // modification, are permitted provided that the following conditions are met:
00009 // 
00010 //  1. Redistributions of source code must retain the above copyright
00011 //     notice, this list of conditions and the following disclaimer.
00012 // 
00013 //  2. Redistributions in binary form must reproduce the above copyright
00014 //     notice, this list of conditions and the following disclaimer in the
00015 //     documentation and/or other materials provided with the distribution.
00016 // 
00017 //  3. The name of the authors may not be used to endorse or promote
00018 //     products derived from this software without specific prior written
00019 //     permission.
00020 // 
00021 // THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
00022 // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00023 // OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
00024 // NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00025 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
00026 // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00027 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00028 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00029 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00030 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00031 // 
00032 // This file is part of the PLearn library. For more information on the PLearn
00033 // library, go to the PLearn Web site at www.plearn.org
00034 
00035 /* *******************************************************      
00036  * $Id: .pyskeleton_header 544 2003-09-01 00:05:31Z plearner $ 
00037  ******************************************************* */
00038 
00039 // Authors: Olivier Delalleau
00040 
00044 #ifndef PLearnDiff_INC
00045 #define PLearnDiff_INC
00046 
00047 #include <plearn/base/Object.h>
00048 
00049 namespace PLearn {
00050 
00052 template<class T> class TMat;
00053 
00054 class PLearnDiff: public Object
00055 {
00056 
00057 private:
00058   
00059     typedef Object inherited;
00060 
00061 protected:
00062 
00063     // *********************
00064     // * protected options *
00065     // *********************
00066 
00067     TMat<string> diffs;
00068 
00069 public:
00070 
00071     // ************************
00072     // * public build options *
00073     // ************************
00074 
00075     real absolute_tolerance;
00076     real relative_tolerance;
00077     bool save_diffs;
00078 
00079     // ****************
00080     // * Constructors *
00081     // ****************
00082 
00084     PLearnDiff();
00085 
00086     // ******************
00087     // * Object methods *
00088     // ******************
00089 
00090 private: 
00092     void build_();
00093 
00094 protected: 
00096     static void declareOptions(OptionList& ol);
00097 
00098 public:
00099     // Declares other standard object methods.
00100     PLEARN_DECLARE_OBJECT(PLearnDiff);
00101 
00102     // simply calls inherited::build() then build_() 
00103     virtual void build();
00104 
00106     virtual void makeDeepCopyFromShallowCopy(CopiesMap& copies);
00107 
00111     int diff(const string& refer, const string& other, const string& name);
00112 
00114     void forget();
00115 
00117     void addDiffPrefix(const string& prefix, int n);
00118 
00126     void printDiffs(PStream& out = pout, unsigned int indent = 2,
00127                     unsigned int tab_step = 20, unsigned int max_width = 120);
00128 
00130     int nDiffs() { return diffs.length(); }
00131 
00135     void setSaveDiffs(bool save_diffs, bool* save_diffs_backup = 0);
00136 
00137 };
00138 
00139 // Declares a few other classes and functions related to this class
00140 DECLARE_OBJECT_PTR(PLearnDiff);
00141 
00144 void addDiffPrefix(PLearnDiff* diffs, const string& prefix, int n);
00145   
00148 int diff(PLearnDiff* diffs, const string& refer, const string& other, const string& name);
00149 
00152 void setSaveDiffs(PLearnDiff* diffs, bool save_diffs,
00153                                      bool* save_diffs_backup = 0);
00154 
00156 real get_absolute_tolerance(PLearnDiff* diffs);
00157 
00159 real get_relative_tolerance(PLearnDiff* diffs);
00160 
00161 } // end of namespace PLearn
00162 
00163 #endif
00164 
00165 
00166 /*
00167   Local Variables:
00168   mode:c++
00169   c-basic-offset:4
00170   c-file-style:"stroustrup"
00171   c-file-offsets:((innamespace . 0)(inline-open . 0))
00172   indent-tabs-mode:nil
00173   fill-column:79
00174   End:
00175 */
00176 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=79 :
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines