/*
** SellaNMS
** $Id: state.h,v 1.6 2005/05/21 23:10:28 sella Exp $
** Copyright (c) 2001-2005 Digital Genesis Software. All Rights Reserved.
** Released under the GPL Version 2 License.
** http://www.digitalgenesis.com
*/

#ifndef __STATE_H__
#define __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 State {
	public:
		State(Storage *s);
		~State();

	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];
};

class ElementState: public State {
	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 State {
	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 State {
	public:
		IPv4State(Storage *s, const char *ip_address);
		IPv4State(Storage *s, const char *ip_address, const char *daemon);

		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
*/
