ROOT logo
// $Id: ZMIR.h 2088 2008-11-23 20:26:46Z matevz $

// Copyright (C) 1999-2008, Matevz Tadel. All rights reserved.
// This file is part of GLED, released under GNU General Public License version 2.
// For the licensing terms see $GLEDSYS/LICENSE or http://www.gnu.org/.

#ifndef Gled_ZMIR_H
#define Gled_ZMIR_H

#include <Gled/GledTypes.h>

class An_ID_Demangler;
class ZMirEmittingEntity;
class SaturnInfo;

#include <TMessage.h>

/*
  TBuffer annotations:
  int Length()		current pos
  SetBufferOffset(int) 	set pos
  Message header 2*UInt_t: length + message type
 */

/**************************************************************************/
// ZMIR
/**************************************************************************/

class ZMIR : public TMessage
{
public:
  enum Direction_e { D_Unknown=0, D_Up, D_Down };

  enum MIR_Bits_e { MB_HeaderWritten      = 1,
		    MB_HasRecipient       = 2,
		    MB_HasResultReq       = 4,
                    MB_DetachedExe        = 8,
                    MB_MultixDetachedExe  = 16,
                    MB_HasChainedMIR      = 32
  };

private:
  void _init();

protected:
  char         *fTrueBuffer;	//!

public:
  Direction_e	fDirection;	         //!
  Bool_t	fSuppressFlareBroadcast; //!
  Bool_t	fRequiresResult;         //!

  UChar_t	fMirBits;
  ID_t		fCallerID;

  ID_t		fRecipientID;		// Must be set via SetRecipient(id)
  ID_t		fResultRecipientID;	// \_ Must be set via
  UInt_t	fResultReqHandle;	// /    SetResultReq(id, handle)

  ID_t		fAlphaID;
  ID_t		fBetaID;
  ID_t		fGammaID;

  LID_t		fLid;
  CID_t		fCid;
  MID_t		fMid;

  // Demangled SaturnIDs; used only on the receiving side.

  ZMirEmittingEntity*	fCaller;	  //!
  SaturnInfo*		fRecipient;	  //!
  SaturnInfo*		fResultRecipient; //!
  ZGlass*		fAlpha;		  //!
  ZGlass*		fBeta;		  //!
  ZGlass*		fGamma;		  //!

  ZMIR(ID_t a=0, ID_t b=0, ID_t g=0);
  ZMIR(ZGlass* a, ZGlass* b=0, ZGlass* g=0);
  ZMIR(TMessage*& m);
  ZMIR(void* buf, Int_t size);
  virtual ~ZMIR();

  Bool_t HasRecipient()	{ return (fMirBits & MB_HasRecipient); }
  Bool_t HasResultReq()	{ return (fMirBits & MB_HasResultReq); }
  Bool_t IsFlare()      { return !HasRecipient(); }
  Bool_t IsBeam()       { return HasRecipient(); }
  Bool_t ShouldExeDetached()   { return (fMirBits & MB_DetachedExe); }
  Bool_t IsDetachedExeMultix() { return (fMirBits & MB_MultixDetachedExe); }
  Bool_t HasChainedMIR()       { return (fMirBits & MB_HasChainedMIR); }

  Bool_t IsMatching(const FID_t& fid) const;
  Bool_t IsMatching(const FID_t& fid, MID_t mid) const;

  Int_t HeaderLength();
  Int_t RoutingHeaderLength();
  void  WriteHeader();
  void  ReadRoutingHeader();
  void  ReadExecHeader();
  void  RewindToData();
  void  RewindToExecHeader();

  // virtual void Reset(); // restore buff from true buf;

  void Demangle(An_ID_Demangler* s) throw(Exc_t);
  void DemangleRecipient(An_ID_Demangler* s) throw(Exc_t);
  void DemangleResultRecipient(An_ID_Demangler* s) throw(Exc_t);

  void SetLCM_Ids(LID_t l, CID_t c, MID_t m) { fLid=l; fCid=c; fMid=m; }
  void SetCaller(ZMirEmittingEntity* caller);
  void SetRecipient(SaturnInfo* recipient);
  void ClearRecipient();
  void SetResultReq(SaturnInfo* r_recipient, UInt_t r_handle);
  void SetDetachedExe(bool multix=false);

  void CopyToBuffer(TBuffer& b);
  void AppendBuffer(TBuffer& b);

  void  ChainMIR(ZMIR* mir);
  ZMIR* UnchainMIR(An_ID_Demangler* s=0);

  ClassDef(ZMIR, 0);
};

inline Bool_t ZMIR::IsMatching(const FID_t& fid) const
{
  return fid.fLid == fLid && fid.fCid == fCid;
}

inline Bool_t ZMIR::IsMatching(const FID_t& fid, MID_t mid) const
{
  return fid.fLid == fLid && fid.fCid == fCid && mid == fMid;
}

/**************************************************************************/
// ZMIR_Result_Report
/**************************************************************************/

class ZMIR_Result_Report : public TBufferFile
{
private:
   ZMIR_Result_Report(const ZMIR_Result_Report &); // not implemented
   void operator=(const ZMIR_Result_Report &);     // not implemented

public:
  enum Bits_e { B_HasException = 1, B_HasResult = 2 };

  UChar_t	fMirRRBits;
  TString	fException;

  ZMIR_Result_Report() : TBufferFile(TBuffer::kWrite) {}
  virtual ~ZMIR_Result_Report() {}

  Bool_t HasException()  { return  fMirRRBits & B_HasException; }
  Bool_t HasResult()     { return  fMirRRBits & B_HasResult; }
  Bool_t Exec_OK()       { return (fMirRRBits & B_HasException) == 0; }
  Bool_t Flare_OK()      { return  Exec_OK(); }
  Bool_t BeamResult_OK() { return (Exec_OK() && HasResult()); }

  const char* GenError(bool report_buffer=true);

  ClassDef(ZMIR_Result_Report, 0);
}; // endclass ZMIR_Result_Report

typedef ZMIR_Result_Report ZMIR_RR;

#endif
 ZMIR.h:1
 ZMIR.h:2
 ZMIR.h:3
 ZMIR.h:4
 ZMIR.h:5
 ZMIR.h:6
 ZMIR.h:7
 ZMIR.h:8
 ZMIR.h:9
 ZMIR.h:10
 ZMIR.h:11
 ZMIR.h:12
 ZMIR.h:13
 ZMIR.h:14
 ZMIR.h:15
 ZMIR.h:16
 ZMIR.h:17
 ZMIR.h:18
 ZMIR.h:19
 ZMIR.h:20
 ZMIR.h:21
 ZMIR.h:22
 ZMIR.h:23
 ZMIR.h:24
 ZMIR.h:25
 ZMIR.h:26
 ZMIR.h:27
 ZMIR.h:28
 ZMIR.h:29
 ZMIR.h:30
 ZMIR.h:31
 ZMIR.h:32
 ZMIR.h:33
 ZMIR.h:34
 ZMIR.h:35
 ZMIR.h:36
 ZMIR.h:37
 ZMIR.h:38
 ZMIR.h:39
 ZMIR.h:40
 ZMIR.h:41
 ZMIR.h:42
 ZMIR.h:43
 ZMIR.h:44
 ZMIR.h:45
 ZMIR.h:46
 ZMIR.h:47
 ZMIR.h:48
 ZMIR.h:49
 ZMIR.h:50
 ZMIR.h:51
 ZMIR.h:52
 ZMIR.h:53
 ZMIR.h:54
 ZMIR.h:55
 ZMIR.h:56
 ZMIR.h:57
 ZMIR.h:58
 ZMIR.h:59
 ZM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