Page.h

00001 # ifndef Conjecture_Page_h
00002 # define Conjecture_Page_h Conjecture_Page_h
00003 
00004 // Insert SVN header substitution variable here
00005 // Class Champion: Unassigned
00006 
00007 // C++ Dependencies
00008 # include <iostream>
00009 # include "Element.h"
00010 
00011 // Declaration
00012 namespace Conjecture {
00013 
00014     // C++ Dependencies
00015     class Env;             // belongs-to
00016     class OCRModule;       // returns
00017     
00047     class Page : public Element {
00048         // For now, Env gets to set certain fields of Page that
00049         // violate total encapsulation. FUTURE FIX: This 'friend'
00050         // statement needs to be refined to a list of methods within
00051         // Env - the current statement is unnecessarily permissive.
00052         // And if possible, the friendship should be removed entirely.
00053         friend class Env;
00054 
00055         // In order to allow all Parts access to an image stored only
00056         // in Page, we must allow Part::image access to
00057         // Page::imageRef()
00058         friend const Image* Element::pageImage() const;
00059 
00060       public:
00061         /*
00062          * The "normal" way to create a Page instance
00063          *
00064          */
00065         Page(Env* env, const std::string& file);
00066 
00067         /*
00068          * A "special" Page constructor used to establish training sets.
00069          *
00070          */
00071         Page(Env* env, const std::string& imagefile, const std::string& validfile);
00072 
00078         virtual bool process();
00079 
00091         virtual bool segment();
00092 
00103         virtual bool identify();
00104 
00118         virtual bool format();
00119 
00125         virtual Page* asPage() { return this; }
00126         virtual const Page* asPage() const { return this; }
00127 
00132         virtual void printSummary(std::ostream& os = std::cerr, const std::string& indent = "", int index = -1) const;
00133 
00142         virtual void writeText(std::ostream& os) const;
00143 
00153         static void test(int argc = 0, const char* argv[] = NULL);
00154 
00155         // *********
00156         // Accessors
00157         inline const Env* env()           const { return this->_env;   }
00158         inline const std::string & file() const { return this->_file;  }
00159         inline const Image*    image()    const { return this->_image; }
00160 
00161       protected:
00162         OCRModule* algorithms() const;
00163 
00164         // *********
00165         // Accessors
00166         inline void envIs(Env* env) { this->_env = env; }
00167         inline void fileIs(const std::string & file) { this->_file = file; }
00168         virtual int type() const    { return Type; }
00169         inline void imageIs(Image* image) { this->_image = image; }
00170 
00171       private:
00172         // *********
00173         // Accessors
00174         inline Env* &          envRef()  { return this->_env;  }
00175         inline std::string &   fileRef() { return this->_file; }
00176         inline Image* &        imageRef() { return this->_image; }
00177 
00178         // *****
00179         // State
00180         static const ElementType Type = ELEMENT_PAGE;
00181 
00199          Env*            _env;
00200 
00201          /*
00202           * The input file to be processed.
00203           *
00204           * This file is also used to establish a prefix for various
00205           * output files.
00206           */
00207          std::string     _file;
00208 
00219          Image*          _image;
00220     };
00221 };
00222 
00223 // C++ Dependencies
00224 # include "Env.h"    // belongs-to
00225 
00226 # endif // Conjecture_Page_h
00227 

Generated on Thu Jun 15 19:56:10 2006 for Conjecture by  doxygen 1.4.6