SNAP Library 2.0, Developer Reference  2013-05-13 16:33:57
SNAP, a general purpose, high performance system for analysis and manipulation of large networks
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
TGBlobBs Class Reference

#include <blobbs.h>

Inheritance diagram for TGBlobBs:
Collaboration diagram for TGBlobBs:

List of all members.

Public Member Functions

 TGBlobBs (const TStr &BlobBsFNm, const TFAccess &_Access=faRdOnly, const int &_MxSegLen=-1)
 ~TGBlobBs ()
TGBlobBsoperator= (const TGBlobBs &)
TStr GetVersionStr () const
TBlobPt PutBlob (const PSIn &SIn)
TBlobPt PutBlob (const TBlobPt &BlobPt, const PSIn &SIn)
PSIn GetBlob (const TBlobPt &BlobPt)
void DelBlob (const TBlobPt &BlobPt)
TBlobPt GetFirstBlobPt ()
TBlobPt FFirstBlobPt ()
bool FNextBlobPt (TBlobPt &TrvBlobPt, TBlobPt &BlobPt, PSIn &BlobSIn)

Static Public Member Functions

static PBlobBs New (const TStr &BlobBsFNm, const TFAccess &Access=faRdOnly, const int &MxSegLen=-1)
static bool Exists (const TStr &BlobBsFNm)

Static Private Member Functions

static TStr GetNrBlobBsFNm (const TStr &BlobBsFNm)

Private Attributes

PFRnd FBlobBs
TFAccess Access
int MxSegLen
TIntV BlockLenV
TBlobPtV FFreeBlobPtV
TBlobPt FirstBlobPt

Detailed Description

Definition at line 154 of file blobbs.h.


Constructor & Destructor Documentation

TGBlobBs::TGBlobBs ( const TStr BlobBsFNm,
const TFAccess _Access = faRdOnly,
const int &  _MxSegLen = -1 
)

Definition at line 220 of file blobbs.cpp.

References Access, TBlobBs::AssertBlobBsStateStr(), TBlobBs::AssertVersionStr(), bbsClosed, bbsOpened, BlockLenV, TFRnd::Empty(), faCreate, Fail, faRdOnly, faRestore, faUpdate, FBlobBs, FFreeBlobPtV, FirstBlobPt, TFRnd::Flush(), TBlobBs::GenBlockLenV(), TBlobBs::GenFFreeBlobPtV(), TBlobBs::GetBlockLenV(), TBlobBs::GetFFreeBlobPtV(), TFRnd::GetFPos(), TBlobBs::GetMxSegLen(), GetNrBlobBsFNm(), TBlobBs::MxBlobFLen, MxSegLen, New(), TBlobBs::PutBlobBsStateStr(), TBlobBs::PutBlockLenV(), TBlobBs::PutFFreeBlobPtV(), TBlobBs::PutMxSegLen(), TBlobBs::PutVersionStr(), and TFRnd::SetFPos().

Referenced by New().

Here is the call graph for this function:

Here is the caller graph for this function:


Member Function Documentation

void TGBlobBs::DelBlob ( const TBlobPt BlobPt) [virtual]

Implements TBlobBs.

Definition at line 353 of file blobbs.cpp.

References Access, TBlobBs::AssertBlobState(), TBlobBs::AssertBlobTag(), BlockLenV, bsActive, bsFree, btBegin, btEnd, EAssert, faCreate, faRestore, faUpdate, FBlobBs, FFreeBlobPtV, TFRnd::Flush(), TBlobPt::GetAddr(), TBlobBs::GetAllocInfo(), TFRnd::GetFPos(), TFRnd::GetInt(), TCh::NullCh, TBlobBs::PutBlobState(), TFRnd::PutCh(), and TFRnd::SetFPos().

Referenced by PutBlob().

                                           {
  EAssert((Access==faCreate)||(Access==faUpdate)||(Access==faRestore));
  FBlobBs->SetFPos(BlobPt.GetAddr());
  AssertBlobTag(FBlobBs, btBegin);
  int MxBfL=FBlobBs->GetInt();
  int FPos=FBlobBs->GetFPos();
  AssertBlobState(FBlobBs, bsActive);
  /*int BfL=*/FBlobBs->GetInt();
  FBlobBs->SetFPos(FPos);
  PutBlobState(FBlobBs, bsFree);
  int _MxBfL; int FFreeBlobPtN;
  GetAllocInfo(MxBfL, BlockLenV, _MxBfL, FFreeBlobPtN);
  EAssert(MxBfL==_MxBfL);
  FFreeBlobPtV[FFreeBlobPtN].SaveAddr(FBlobBs);
  FFreeBlobPtV[FFreeBlobPtN]=BlobPt;
  FBlobBs->PutCh(TCh::NullCh, MxBfL+sizeof(TCs));
  AssertBlobTag(FBlobBs, btEnd);
  FBlobBs->Flush();
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool TGBlobBs::Exists ( const TStr BlobBsFNm) [static]

Definition at line 410 of file blobbs.cpp.

References GetNrBlobBsFNm().

                                          {
  TStr NrBlobBsFNm=GetNrBlobBsFNm(BlobBsFNm);
  return TFile::Exists(NrBlobBsFNm);
}

Here is the call graph for this function:

Implements TBlobBs.

Definition at line 373 of file blobbs.cpp.

References FirstBlobPt.

                              {
  return FirstBlobPt;
}
bool TGBlobBs::FNextBlobPt ( TBlobPt TrvBlobPt,
TBlobPt BlobPt,
PSIn BlobSIn 
) [virtual]

Implements TBlobBs.

Definition at line 377 of file blobbs.cpp.

References TBlobBs::AssertBfCsEqFlCs(), TBlobBs::AssertBlobTag(), bsActive, bsFree, btBegin, btEnd, TBlobPt::Clr(), Fail, FBlobBs, forever, TBlobPt::GetAddr(), TBlobBs::GetBlobState(), TFRnd::GetCs(), TFRnd::GetFLen(), TFRnd::GetFPos(), TFRnd::GetInt(), TFRnd::GetSIn(), TFRnd::MoveFPos(), and TFRnd::SetFPos().

                                                                            {
  forever {
    uint TrvBlobAddr=TrvBlobPt.GetAddr();
    if (TrvBlobAddr>=uint(FBlobBs->GetFLen())){
      TrvBlobPt.Clr(); BlobPt.Clr(); BlobSIn=NULL;
      return false;
    } else {
      FBlobBs->SetFPos(TrvBlobAddr);
      AssertBlobTag(FBlobBs, btBegin);
      int MxBfL=FBlobBs->GetInt();
      TBlobState BlobState=GetBlobState(FBlobBs);
      switch (BlobState){
        case bsActive:{
          int BfL=FBlobBs->GetInt();
          TCs BfCs; BlobSIn=FBlobBs->GetSIn(BfL, BfCs);
          FBlobBs->MoveFPos(MxBfL-BfL);
          TCs FCs=FBlobBs->GetCs();
          AssertBlobTag(FBlobBs, btEnd);
          AssertBfCsEqFlCs(BfCs, FCs);
          BlobPt=TrvBlobPt;
          TrvBlobPt=TBlobPt(FBlobBs->GetFPos());
          return true;}
        case bsFree:
          FBlobBs->MoveFPos(sizeof(uint)+MxBfL+sizeof(TCs));
          AssertBlobTag(FBlobBs, btEnd);
          TrvBlobPt=TBlobPt(FBlobBs->GetFPos());
          break;
        default: Fail; return false;
      }
    }
  }
}

Here is the call graph for this function:

PSIn TGBlobBs::GetBlob ( const TBlobPt BlobPt) [virtual]
TBlobPt TGBlobBs::GetFirstBlobPt ( ) [inline, virtual]

Implements TBlobBs.

Definition at line 179 of file blobbs.h.

References FirstBlobPt.

{return FirstBlobPt;}
TStr TGBlobBs::GetNrBlobBsFNm ( const TStr BlobBsFNm) [static, private]

Definition at line 213 of file blobbs.cpp.

References TStr::Empty(), and TStr::GetFExt().

Referenced by Exists(), and TGBlobBs().

                                                  {
  TStr NrBlobBsFNm=BlobBsFNm;
  if (NrBlobBsFNm.GetFExt().Empty()){
    NrBlobBsFNm=NrBlobBsFNm+".gbb";}
  return NrBlobBsFNm;
}

Here is the call graph for this function:

Here is the caller graph for this function:

TStr TGBlobBs::GetVersionStr ( ) const [inline, virtual]

Implements TBlobBs.

Definition at line 173 of file blobbs.h.

{return TStr("General Blob Base Format 1.0");}
static PBlobBs TGBlobBs::New ( const TStr BlobBsFNm,
const TFAccess Access = faRdOnly,
const int &  MxSegLen = -1 
) [inline, static]

Definition at line 166 of file blobbs.h.

References Access, MxSegLen, and TGBlobBs().

Referenced by TGBlobBs(), and TMBlobBs::TMBlobBs().

                          {
    return PBlobBs(new TGBlobBs(BlobBsFNm, Access, MxSegLen));}

Here is the call graph for this function:

Here is the caller graph for this function:

TGBlobBs& TGBlobBs::operator= ( const TGBlobBs ) [inline]

Definition at line 171 of file blobbs.h.

References Fail.

{Fail; return *this;}
TBlobPt TGBlobBs::PutBlob ( const PSIn SIn) [virtual]

Implements TBlobBs.

Definition at line 275 of file blobbs.cpp.

References Access, TBlobBs::AssertBlobState(), TBlobBs::AssertBlobTag(), BlockLenV, bsActive, bsFree, btBegin, btEnd, EAssert, faCreate, faRestore, faUpdate, FBlobBs, FFreeBlobPtV, TFRnd::Flush(), TBlobPt::GetAddr(), TBlobBs::GetAllocInfo(), TFRnd::GetFLen(), TFRnd::GetFPos(), TFRnd::GetInt(), TSIn::Len(), TBlobPt::LoadAddr(), TBlobBs::MxBlobFLen, MxSegLen, TCh::NullCh, TBlobBs::PutBlobState(), TBlobBs::PutBlobTag(), TFRnd::PutCh(), TFRnd::PutCs(), TFRnd::PutInt(), TFRnd::PutSIn(), and TFRnd::SetFPos().

Referenced by PutBlob().

                                        {
  EAssert((Access==faCreate)||(Access==faUpdate)||(Access==faRestore));
  int BfL=SIn->Len();
  int MxBfL; int FFreeBlobPtN;
  GetAllocInfo(BfL, BlockLenV, MxBfL, FFreeBlobPtN);
  TBlobPt BlobPt; TCs Cs;
  if (FFreeBlobPtV[FFreeBlobPtN].Empty()){
    int FLen=FBlobBs->GetFLen();
    if (FLen<=MxSegLen){
      EAssert(FLen<=MxBlobFLen);
      BlobPt=TBlobPt(FLen);
      FBlobBs->SetFPos(BlobPt.GetAddr());
      PutBlobTag(FBlobBs, btBegin);
      FBlobBs->PutInt(MxBfL);
      PutBlobState(FBlobBs, bsActive);
      FBlobBs->PutInt(BfL);
      FBlobBs->PutSIn(SIn, Cs);
      FBlobBs->PutCh(TCh::NullCh, MxBfL-BfL);
      FBlobBs->PutCs(Cs);
      PutBlobTag(FBlobBs, btEnd);
    }
  } else {
    BlobPt=FFreeBlobPtV[FFreeBlobPtN];
    FBlobBs->SetFPos(BlobPt.GetAddr());
    AssertBlobTag(FBlobBs, btBegin);
    int MxBfL=FBlobBs->GetInt();
    int FPos=FBlobBs->GetFPos();
    AssertBlobState(FBlobBs, bsFree);
    FFreeBlobPtV[FFreeBlobPtN]=TBlobPt::LoadAddr(FBlobBs);
    FBlobBs->SetFPos(FPos);
    PutBlobState(FBlobBs, bsActive);
    FBlobBs->PutInt(BfL);
    FBlobBs->PutSIn(SIn, Cs);
    FBlobBs->PutCh(TCh::NullCh, MxBfL-BfL);
    FBlobBs->PutCs(Cs);
    AssertBlobTag(FBlobBs, btEnd);
  }
  FBlobBs->Flush();
  return BlobPt;
}

Here is the call graph for this function:

Here is the caller graph for this function:

TBlobPt TGBlobBs::PutBlob ( const TBlobPt BlobPt,
const PSIn SIn 
) [virtual]

Member Data Documentation

Definition at line 157 of file blobbs.h.

Referenced by DelBlob(), New(), PutBlob(), TGBlobBs(), and ~TGBlobBs().

Definition at line 159 of file blobbs.h.

Referenced by DelBlob(), PutBlob(), TGBlobBs(), and ~TGBlobBs().

Definition at line 156 of file blobbs.h.

Referenced by DelBlob(), FNextBlobPt(), GetBlob(), PutBlob(), TGBlobBs(), and ~TGBlobBs().

Definition at line 160 of file blobbs.h.

Referenced by DelBlob(), PutBlob(), TGBlobBs(), and ~TGBlobBs().

Definition at line 161 of file blobbs.h.

Referenced by FFirstBlobPt(), GetFirstBlobPt(), and TGBlobBs().

int TGBlobBs::MxSegLen [private]

Definition at line 158 of file blobbs.h.

Referenced by New(), PutBlob(), TGBlobBs(), and ~TGBlobBs().


The documentation for this class was generated from the following files: