/*
** SellaNMS
** $Id: state.h,v 1.8 2005/11/06 04:58:25 sella Exp $
** Copyright (c) 2001-2005 Digital Genesis Software. All Rights Reserved.
** Released under the GPL Version 2 License.
** http://www.digitalgenesis.com
*/

#ifndef __DGS_STATE_H__
#define __DGS_STATE_H__

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

#include "common/storagedata.h"
#include "storage/storage.h"
#include "policy_framework/policy_framework.h"
#include <time.h>

class BaseState {
	public:
		BaseState(Storage *s);
		~BaseState();
		void updateTimestamp(bool flag);

	protected:
		void set(const char *daemon, const char *table, int index, const char *state);
		void set(const char *daemon, const char *table, int index, const char *state, int depth);
		char *get(const char *daemon, const char *table, int index, char *state, size_t statelen);

		int getChangeCount(const char *daemon, const char *table, int index);
		time_t getChangeTime(const char *daemon, const char *table, int index);
		void resetChangeCount(const char *daemon, const char *table, int index);

		Storage	*storage;
		char		daemon[64];
		char		state[64];
		bool		updateTs;
};

class ElementState: public BaseState {
	public:
		ElementState(Storage *s, int e);
		ElementState(Storage *s, int e, const char *daemon);

		void set(const char *state);
		char *get();

		int getChangeCount();
		void resetChangeCount();

		time_t getChangeTime();

	protected:
		long	element;
};

class InterfaceState: public BaseState {
	public:
		InterfaceState(Storage *s, int i);
		InterfaceState(Storage *s, int i, const char *daemon);

		void set(const char *state);
		char *get();

		int getChangeCount();
		void resetChangeCount();

		time_t getChangeTime();

	protected:
		long	interface;
};

class IPv4State: public BaseState {
	public:
		IPv4State(Storage *s, const char *ip_address);
		IPv4State(Storage *s, const char *ip_address, const char *daemon);
		IPv4State(Storage *s, int i, const char *daemon);
		IPv4State(Storage *s, int i);

		void set(const char *state);
		char *get();

		int getChangeCount();
		void resetChangeCount();

		time_t getChangeTime();

	protected:
		long	ipv4;
};

#endif

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