//
//
// Logs:
//
//  $Log: LServer.h,v $
//  Revision 1.5  2003/11/24 17:06:23  cvs
//  a bug was corrected in LServer::GetLData and the error bars were corrected when drawing Draw(".tof.")
//
//  Revision 1.4  2003/11/11 17:33:03  cvs
//  LServer upgraded
//
//  Revision 1.3  2003/07/09 10:53:13  cvs
//  added some verbosity and changed LContainer class. The LData isnt changed. Corrected daemon mode of hoppserv, since network connection is dependend on process pid. So the connection should be opened by child processes.
//
//  Revision 1.2  2003/06/26 09:27:11  cvs
//  added log fields...
//
#ifndef _LSERVER___
#define _LSERVER___

#include "Config.h"

#include <TFile.h>
#include <TString.h>
#include <TList.h>
#include "LDataHeader.h"
#include "LData.h"
#include "LContainer.h"
#include "TLClient.h"
#include "LClientTypes.h"
#include "LRunCommands.h"

class LServer:public TObject {
 private:
  ELClientTypes fclient;//who wants to talk
  TLClient* fsocket; //connection socket
  TString* fname; //ROOT filename
  TFile* fdatabase; //ROOT file
  int fsyslog; //syslog daemon 
  char fStr[80];
  LData* fdata;//LData object
  LDataHeader* fheader;//LDataHeader object

 public:
  LServer(TLClient* calling,const char* filename="",int syslogd=0);
  virtual ~LServer();

  void Serving();
  void SetSysLog();

 private:

  Int_t SendLog(const char* message);
  Bool_t ReceiveString();
  int WaitConnection();

  Int_t DataTransfer(LData* data);
  Int_t DataContainerTransfer(LContainer* data);
  Int_t DataHeaderTransfer(LDataHeader* header);

  TDirectory* MkDirectory(LDataHeader* header);
  TDirectory* CdDirectory(Long_t jobID);
  TFile* OpenDataBase();
  void CloseDataBase();
  LData* GetLData(Long_t jobID);

  ClassDef(LServer,0)  //Networking server 
};

#endif //_LSERVER___



