/*
** SellaNMS
** $Id: output.h,v 1.17 2005/05/15 05:21:17 sella Exp $
** Copyright (c) 2001-2005 Digital Genesis Software, LLC. All Rights Reserved.
** Released under the GPL Version 2 License.
** http://www.digitalgenesis.com
*/

#ifndef __DGS_MODULE_OUTPUT_H
#define __DGS_MODULE_OUTPUT_H

#ifdef HAVE_CONFIG_H
	#include "config.h"
#endif

#include "defaults.h"
#include "util.h"
#include "../module.h"
#include "storage/storage.h"
#include "policy_framework/policy_framework.h"
#include <time.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/time.h>
#include <stl/list>
#include <stl/vector>
#include <stl/string>

#define MODULE_OUTPUT_AGEMAX_DEFAULT 300
#define MODULE_OUTPUT_AGEINTERVAL_DEFAULT 30
#define MODULE_OUTPUT_QUEUEDEPTH_DEFAULT 100

typedef struct output_t {
   unsigned long	id;
  	string			timestamp;
	time_t			unix_timestamp;
   string			address;
   string			interface;
   string			element;
   string			module;
   string			protocol;
   string			channel;
   string			status;
   string			brief;
   string			detail;
} _output_t;

class Output: public Module {
	public:
		Output();
		virtual ~Output();

	protected:
		virtual RESULT handleTraceOptions();
		virtual RESULT readOutput(const string &module, bool auto_delete = true);
		virtual RESULT deleteOutput(slist<unsigned long> &output_ids);

		virtual RESULT policyInputNext(variable_binding_t &policy_input);
		virtual RESULT policyInputAll(slist<variable_binding_t> &policy_input_list);

		virtual bool outputEmpty() const;

		unsigned long queueDepth;

		variable_binding_t polInput;
		variable_binding_t polOutput;
		variable_binding_t polInputDefault;

		Storage storage;

		PolicyFramework inputPolicy;
		PolicyFramework outputPolicy;

	private:
		virtual RESULT execute();
		virtual RESULT readConfig();
		RESULT clearStaleData();

		slist<output_t> output;

		unsigned long age_max;
		unsigned long age_interval;
};

#endif

/*
** Local Variables:
** c-basic-offset: 3
** tab-width: 3
** End:
** vim600: fdm=marker
** vim: noet ts=3 sw=3
*/
