
#include "RobboBaseLibExternal.h"

/************* score */

boolean RobboTotalLibScore (Type_PiSq* PiSq, uint8* Value, int type)
{
  return fare_PQ_with_ep_with_type (PiSq, Value, type);
}

boolean RobboTripleLibScore (Type_PiSq* PiSq, int* Value, int type)
{
  return robbo_triple_lib_score (PiSq, Value, type);
}

/*************** Total set up */

int RegisterTotalBases (char* DIRECTORY_MASTER) /* RobboTotal_iniz.c */
{
  return RegisterRobboTotalBases (DIRECTORY_MASTER);
}

int DeRegisterTotalBases () /* RobboTotal_iniz.c */
{
  return DeRegisterRobboTotalBases ();
}

void RegisterRobboTotalBasesInDirectory (char* DIRECTORY)
{
  GetTotalBase (DIRECTORY); /* RobboTotal_iniz.c */
}

int SetCacheTotalBase (int mega_bytes) /* Default 1 */
{
  return SetTotalBaseCache (mega_bytes);
}

int HAS_TotalBase (Type_PiSq *PiSq)
{
  return RobboHasTotalBase (PiSq);
}

/************ Triple set up */

int SetCacheTripleBase (int mega_bytes) /* Default 1 */
{
  return SetTripleBaseCache (mega_bytes);
}


/* weak probe, back ground */

boolean BACK_GROUND = FALSE;
boolean SetLoadOnWeakProbeBackGround (boolean type)
{
  if (!BACK_GROUND)
    return FALSE;
  return weak_probe_modify (type, -1);
}

boolean AllowBackGroundLoader ()
{
  if (!BACK_GROUND)
    return FALSE;
  return weak_probe_modify (-1, 1);
}

boolean PauseBackGroundLoader ()
{
  if (!BACK_GROUND)
    return FALSE;
  return weak_probe_modify (-1, 0);
}


/* Load and UnLoad */

int LoadTripleBases (char* DIRECTORY_MASTER) /* RobboTriple.c */
{
  return LoadRobboTripleBases (DIRECTORY_MASTER);
}

int UnLoadTripleBases () /* RobboTriple.c */
{
  return UnLoadRobboTripleBases ();
}

void LoadRobboTripleBasesInDirectory (char* DIRECTORY) /* RobboTriple.c */
{
  GetTripleBase (DIRECTORY); /* RobboTriple.c */
}

int HAS_TripleBase (Type_PiSq *PiSq)
{
  return RobboHasTripleBase (PiSq);
}

/* Bulk */

void RobboLibBulkLoadFile (char* FILE_NAME) /* one file, RobboTriple_iniz.c */
{
  RobboBulkLoadFile (FILE_NAME);
}

void RobboLibBulkDetachFile (char *FILE_NAME)
{
  RobboBulkDetachFile (FILE_NAME);
}

void RobboLibBulkLoadDirectory (char* FILE_NAME) /* RobboTriple_iniz.c */
{
  RobboBulkLoadDirectory (FILE_NAME);
}

void RobboLibBulkDetachDirectory (char* FILE_NAME) /* RobboTriple_iniz.c */
{
  RobboBulkDetachDirectory (FILE_NAME);
}

/*************** start up, exit */

void RobboBaseLibStartUp (boolean back_ground)
{
  TotalBaseInit ();
  INIT_TRIPLE_BASE ();
  magic_mult_init ();
  BACK_GROUND = back_ground;
  if (back_ground)
    InitBackGroundLoader ();
}

void RobboBaseLibExit ()
{
  CleanupTriple ();
}

void GetRobboBaseLibraryVersion (char * STRING)
{
  strcpy (STRING, VERSION);
}

/**** Utility */

void TotalBase_FileNames (Type_PiSq * PiSq, char * BUFFER)
{
  EmitTotalFileNames (PiSq, BUFFER);
}

void TripleBase_FileNames (Type_PiSq * PiSq, char * BUFFER)
{
  EmitTripleFileNames (PiSq, BUFFER);
}

void FilesInfo_TotalBase (Type_PiSq * PiSq, char * BUFFER)
{
  EmitTotalFilesInfo (PiSq, BUFFER);
}

void FilesInfo_TripleBase (Type_PiSq * PiSq, char * BUFFER)
{
  EmitTripleFilesInfo (PiSq, BUFFER);
}

/** Others **/
int GetMaximumTriplePieces ()
{
  return TripleUsage ();
}

void ResetTripleCounters ()
{
  TripleEnumerateReset ();
}

void SendTripleCounters ()
{
  AkinRobboInformatory (0);
}
