00001 /* 00002 * Copyright (c) 2004 CSIRO ICT Centre 00003 * 00004 * $Id: ObjectPairConsumer.h 587 2004-12-03 15:06:33Z nch $ 00005 */ 00006 00007 /* 00008 * A consumer of object pairs. This class counts the number 00009 * of object pairs reported and forwards them to the pair writer 00010 * provided to the constructir, if any. 00011 * 00012 * When finished called, the number of object pairs processed 00013 * is printed to stdout. 00014 * 00015 * The default behaviour is to write out the object pairs as they 00016 * are reported. For further refinement, refer to the class 00017 * ObjectPairRefineConsumer, which includes a further refinement 00018 * step that needs to be successful before writing is performed. 00019 * 00020 * This class should be used to count (and possible write) those 00021 * pairs of objects that fail to meet the further refinement 00022 * criteria. 00023 * 00024 * Refer to the class Refine class for details. 00025 * 00026 * This class owns the ObjectPairWriter and deletes it in the destructor. 00027 */ 00028 00029 #ifndef OBJECTPAIRCONSUMER_DEFINED 00030 #define OBJECTPAIRCONSUMER_DEFINED 00031 00032 #include "ObjectPairWriter.h" 00033 #include "String.h" 00034 00035 class Object; 00036 00037 00038 class ObjectPairConsumer 00039 { 00040 public: 00041 ObjectPairConsumer(String const & name, 00042 ObjectPairWriter * writer=0); 00043 virtual ~ObjectPairConsumer(); 00044 String const & getName() const { return m_name; }; 00045 virtual bool report(Object const * redObject, Object const * blueObject) 00046 { 00047 if (m_writer != 0) 00048 m_writer->write(redObject, blueObject); 00049 m_count++; 00050 return true; 00051 } 00052 virtual void finished(); 00053 00054 protected: 00055 ObjectPairWriter * m_writer; 00056 unsigned long long m_count; 00057 00058 private: 00059 String m_name; 00060 00061 ObjectPairConsumer(ObjectPairConsumer const &); 00062 ObjectPairConsumer & operator=(ObjectPairConsumer const &); 00063 }; 00064 00065 #endif // ifndef OBJECTPAIRCONSUMER_DEFINED 00066