#ifndef n_FileKeeper_H
#define n_FileKeeper_H

/*
 *
 * nucleo/core/FileKeeper.H --
 *
 * Copyright (C) Nicolas Roussel
 *
 * See the file LICENSE for information on usage and redistribution of
 * this file, and for a DISCLAIMER OF ALL WARRANTIES.
 *
 */

#include <nucleo/core/ReactiveObject.H>

namespace nucleo {

  class FileKeeper : public Observable {

  public:

    typedef enum {NOTHING=0,R=1,W=2,RW=3,E=4,RWE=7} eventMask ;

  protected:
    
    int _fd ;
    eventMask _mask ;

    FileKeeper(void) {
	 _fd = -1 ;
	 _mask = NOTHING ;
    }

  public:

    virtual void setup(int fd, eventMask mask) {
	 _fd = fd ;
	 _mask = mask ;
    }

    int getFd(void) { return _fd ; }
    eventMask getEventMask(void) { return _mask ; }

    eventMask getState(void) ;

    static FileKeeper* create(void) ;

    static FileKeeper* create(int fd, eventMask mask) {
	 FileKeeper *fk = create() ;
	 fk->setup(fd, mask) ;
	 return fk ;
    }

  } ;

}

#endif
