Use ACL instead of AXE for utilities
[gnucomo.git] / src / gcm_input / message.h
index eb32449..98f2d1b 100644 (file)
@@ -8,7 +8,7 @@
 ***********************
 **      FILE NAME      : message.h
 **      SYSTEM NAME    : 
-**      VERSION NUMBER : $Revision: 1.7 $
+**      VERSION NUMBER : $Revision: 1.8 $
 **
 **  DESCRIPTION      :  Classes to for handling client messages
 **
 
 /*****************************
    $Log: message.h,v $
-   Revision 1.7  2003-08-11 16:56:16  arjen
+   Revision 1.8  2003-12-04 10:38:09  arjen
+   Major redesign. All input is handled through XML. Raw input data is first
+   transformed into an XML document for further processing.
+   A collection of polymorphic classes handle the transformation of various
+   input formats into XML.
+   Classifying input data is done with a finite improbability calculation.
+
+   Revision 1.7  2003/08/11 16:56:16  arjen
    Different kinds of log files are parsed by a collection of objects
    of different classes, derived from the base class line_cooker
    Depending on the message content or the message_type element in
 
 *****************************/
 
-/* static const char *RCSID = "$Id: message.h,v 1.7 2003-08-11 16:56:16 arjen Exp $"; */
+/* static const char *RCSID = "$Id: message.h,v 1.8 2003-12-04 10:38:09 arjen Exp $"; */
 
 #include <iostream>
 #include <list>
-#include <AXE/String.h>
-#include <AXE/date.h>
+#include <String.h>
+#include <date.h>
 
 #include <libxml/parser.h>
 
+#include "message_filter.h"
 #include "line_cooker.h"
 #include "database.h"
 
-/*
-///////////////////////////////////////////////////////////////////////////
-//  NAME           : message_buffer
-//  BASECLASS      : 
-//  MEMBERS        :
-//  OPERATORS      :
-//  METHODS        : rewind()
-//
-//  DESCRIPTION    : 
-//
-//  RELATIONS      :
-//  SEE ALSO       :
-//  LAST MODIFIED  : Nov 04, 2002
-///////////////////////////////////////////////////////////////////////////
-*/
+//  Associates line cookers and message filters
 
-class message_buffer
+struct xform
 {
-   std::istream       *input;
-   std::list<String>  buffer;
-
-   std::list<String>::iterator   next_line;
-
-public:
+   message_filter    *mf;
+   line_cooker       *lc;
+   double            uncertainty;
 
-   message_buffer()
+   xform()
    {
-      input = 0;
-      next_line = buffer.begin();
+      mf = NULL;
+      lc = NULL;
+      uncertainty = 1.0;
    }
 
-   message_buffer(std::istream *in)
+   xform(message_filter *m, line_cooker *l)
    {
-      input = in;
-      next_line = buffer.begin();
-   }
-
-   void from(std::istream *in)
-   {
-      input = in;
-   }
-
-   friend bool operator >> (message_buffer &, String &);
-
-   void rewind()
-   {
-      next_line = buffer.begin();
-   }
-
-   void operator ++()
-   {
-      if (next_line != buffer.end())
-      {
-         next_line++;
-      }
-   }
-
-   void operator --()
-   {
-      if (next_line != buffer.begin())
-      {
-         next_line--;
-      }
+      mf = m;
+      lc = l;
+      uncertainty = 1.0;
    }
 };
 
@@ -162,13 +127,14 @@ class client_message
    UTC        arrival;       //  When we got the message.
    String     service;       //  Service that created the message
 
-   std::list<line_cooker *>  kitchen;   //  The collection of line cookers
-   line_cooker           *   pan;       //  The one we cook this log with
+   std::list<xform>  kitchen;   //  The collection of message filters and line cookers
+   xform             pan;       //  The one we cook this log with
 
    bool       mail_header;   //  Does the message contain a mail header ?
    bool       gpg_encrypted; //  Is the message encrypted ?
 
-   xmlDocPtr  xmlDom;
+   std::strstream  xmlBuffer;
+   xmlDocPtr       xmlDom;
 
    double     certainty;     //  How certain are we about the message
    enum
@@ -180,16 +146,18 @@ class client_message
    message_buffer    input;
    gnucomo_database  database;
 
-   int     readXMLinput(String first_line);
    void    enterXML();
+   bool    extractHeader();
 
 public:
 
    client_message(std::istream *in, gnucomo_database db);
 
-   void   add_cooker(line_cooker *lc)
+   void   add_cooker(line_cooker *lc, message_filter *mf)
    {
-      kitchen.push_back(lc);
+      xform x(mf, lc);
+
+      kitchen.push_back(x);
    }
 
    double classify(String host, UTC arrival = Now(), String serv = "");