#include "oldlist.h"
#include "intproto.h"
#include <cstdio>
Go to the source code of this file.
◆ ConfigIsPermanent
#define ConfigIsPermanent |
( |
|
Class, |
|
|
|
ConfigId |
|
) |
| (test_bit ((Class)->PermConfigs, ConfigId)) |
◆ IncreaseConfidence
#define IncreaseConfidence |
( |
|
TempConfig | ) |
((TempConfig)->NumTimesSeen++) |
◆ IsEmptyAdaptedClass
#define IsEmptyAdaptedClass |
( |
|
Class | ) |
|
Value:((Class)->NumPermConfigs == 0 && \
Definition at line 89 of file adaptive.h.
◆ MakeConfigPermanent
#define MakeConfigPermanent |
( |
|
Class, |
|
|
|
ConfigId |
|
) |
| (SET_BIT ((Class)->PermConfigs, ConfigId)) |
◆ MakeProtoPermanent
#define MakeProtoPermanent |
( |
|
Class, |
|
|
|
ProtoId |
|
) |
| (SET_BIT ((Class)->PermProtos, ProtoId)) |
◆ NumNonEmptyClassesIn
#define NumNonEmptyClassesIn |
( |
|
Template | ) |
((Template)->NumNonEmptyClasses) |
◆ PermConfigFor
#define PermConfigFor |
( |
|
Class, |
|
|
|
ConfigId |
|
) |
| ((Class)->Config[ConfigId].Perm) |
◆ TempConfigFor
#define TempConfigFor |
( |
|
Class, |
|
|
|
ConfigId |
|
) |
| ((Class)->Config[ConfigId].Temp) |
◆ ADAPT_CLASS
◆ ADAPT_TEMPLATES
◆ PERM_CONFIG
◆ TEMP_CONFIG
◆ TEMP_PROTO
◆ AddAdaptedClass()
This routine adds a new adapted class to an existing set of adapted templates.
- Parameters
-
Templates | set of templates to add new class to |
Class | new class to add to templates |
ClassId | class id to associate with new class |
- Note
- Globals: none
Definition at line 46 of file adaptive.cpp.
51 assert (Templates !=
nullptr);
52 assert (Class !=
nullptr);
60 assert (Templates->
Class[ClassId] ==
nullptr);
61 Templates->
Class[ClassId] = Class;
#define UnusedClassIdIn(T, c)
ADAPT_CLASS Class[MAX_NUM_CLASSES]
void AddIntClass(INT_TEMPLATES Templates, CLASS_ID ClassId, INT_CLASS Class)
INT_CLASS NewIntClass(int MaxNumProtos, int MaxNumConfigs)
◆ free_adapted_class()
Definition at line 125 of file adaptive.cpp.
void FreeBitVector(BIT_VECTOR BitVector)
#define TempConfigFor(Class, ConfigId)
void FreeTempConfig(TEMP_CONFIG Config)
void destroy_nodes(LIST list, void_dest destructor)
#define PermConfigFor(Class, ConfigId)
#define ConfigIsPermanent(Class, ConfigId)
void FreeTempProto(void *arg)
◆ free_adapted_templates()
Definition at line 183 of file adaptive.cpp.
185 if (templates !=
nullptr) {
186 for (
int i = 0; i < (templates->
Templates)->NumClasses; i++)
void free_int_templates(INT_TEMPLATES templates)
ADAPT_CLASS Class[MAX_NUM_CLASSES]
void free_adapted_class(ADAPT_CLASS adapt_class)
◆ FreeTempConfig()
This routine frees all memory consumed by a temporary configuration.
- Parameters
-
- Note
- Globals: none
Definition at line 75 of file adaptive.cpp.
76 assert (
Config !=
nullptr);
void FreeBitVector(BIT_VECTOR BitVector)
◆ FreeTempProto()
void FreeTempProto |
( |
void * |
arg | ) |
|
◆ NewAdaptedClass()
This operation allocates and initializes a new adapted class data structure and returns a ptr to it.
- Returns
- Ptr to new class data structure.
- Note
- Globals: none
Definition at line 103 of file adaptive.cpp.
ADAPT_CLASS_STRUCT * ADAPT_CLASS
#define WordsInVectorOfSize(NumBits)
#define zero_all_bits(array, length)
#define TempConfigFor(Class, ConfigId)
BIT_VECTOR NewBitVector(int NumBits)
◆ NewTempConfig()
TEMP_CONFIG NewTempConfig |
( |
int |
MaxProtoId, |
|
|
int |
FontinfoId |
|
) |
| |
This routine allocates and returns a new temporary config.
- Parameters
-
MaxProtoId | max id of any proto in new config |
FontinfoId | font information from pre-trained templates |
- Returns
- Ptr to new temp config.
- Note
- Globals: none
Definition at line 204 of file adaptive.cpp.
205 int NumProtos = MaxProtoId + 1;
211 Config->MaxProtoId = MaxProtoId;
214 Config->FontinfoId = FontinfoId;
TEMP_CONFIG_STRUCT * TEMP_CONFIG
#define WordsInVectorOfSize(NumBits)
#define zero_all_bits(array, length)
BIT_VECTOR NewBitVector(int NumBits)
◆ NewTempProto()
This routine allocates and returns a new temporary proto.
- Returns
- Ptr to new temporary proto.
- Note
- Globals: none
Definition at line 229 of file adaptive.cpp.
◆ ReadAdaptedClass()
Read an adapted class description from file and return a ptr to the adapted class.
- Parameters
-
fp | open file to read adapted class from |
- Returns
- Ptr to new adapted class.
- Note
- Globals: none
Definition at line 282 of file adaptive.cpp.
301 fp->
FRead(&NumTempProtos,
sizeof(
int), 1);
303 for (i = 0; i < NumTempProtos; i++) {
310 fp->
FRead(&NumConfigs,
sizeof(
int), 1);
311 for (i = 0; i < NumConfigs; i++)
int FRead(void *buffer, size_t size, int count)
ADAPT_CLASS_STRUCT * ADAPT_CLASS
#define WordsInVectorOfSize(NumBits)
TEMP_CONFIG ReadTempConfig(TFile *fp)
BIT_VECTOR NewBitVector(int NumBits)
LIST push_last(LIST list, void *item)
ADAPTED_CONFIG Config[MAX_NUM_CONFIGS]
TEMP_PROTO_STRUCT * TEMP_PROTO
#define test_bit(array, bit)
PERM_CONFIG ReadPermConfig(TFile *fp)
◆ ReadPermConfig()
Read a permanent configuration description from file and return a ptr to it.
- Parameters
-
fp | open file to read permanent config from |
- Returns
- Ptr to new permanent configuration description.
- Note
- Globals: none
Definition at line 363 of file adaptive.cpp.
366 fp->
FRead(&NumAmbigs,
sizeof(NumAmbigs), 1);
369 Config->Ambigs[NumAmbigs] = -1;
int FRead(void *buffer, size_t size, int count)
PERM_CONFIG_STRUCT * PERM_CONFIG
◆ ReadTempConfig()
Read a temporary configuration description from file and return a ptr to it.
- Parameters
-
fp | open file to read temporary config from |
- Returns
- Ptr to new temporary configuration description.
- Note
- Globals: none
Definition at line 387 of file adaptive.cpp.
int FRead(void *buffer, size_t size, int count)
TEMP_CONFIG_STRUCT * TEMP_CONFIG
BIT_VECTOR NewBitVector(int NumBits)
◆ WriteAdaptedClass()
void WriteAdaptedClass |
( |
FILE * |
File, |
|
|
ADAPT_CLASS |
Class, |
|
|
int |
NumConfigs |
|
) |
| |
This routine writes a binary representation of Class to File.
- Parameters
-
File | open file to write Class to |
Class | adapted class to write to File |
NumConfigs | number of configs in Class |
- Note
- Globals: none
Definition at line 410 of file adaptive.cpp.
426 fwrite(&NumTempProtos,
sizeof(
int), 1, File);
434 fwrite(&NumConfigs,
sizeof(
int), 1, File);
435 for (i = 0; i < NumConfigs; i++)
void WritePermConfig(FILE *File, PERM_CONFIG Config)
#define WordsInVectorOfSize(NumBits)
void WriteTempConfig(FILE *File, TEMP_CONFIG Config)
ADAPTED_CONFIG Config[MAX_NUM_CONFIGS]
#define test_bit(array, bit)
◆ WritePermConfig()
void WritePermConfig |
( |
FILE * |
File, |
|
|
PERM_CONFIG |
Config |
|
) |
| |
This routine writes a binary representation of a permanent configuration to File.
- Parameters
-
File | open file to write Config to |
Config | permanent config to write to File |
- Note
- Globals: none
Definition at line 482 of file adaptive.cpp.
483 uint8_t NumAmbigs = 0;
485 assert (
Config !=
nullptr);
486 while (
Config->Ambigs[NumAmbigs] > 0) ++NumAmbigs;
488 fwrite(&NumAmbigs,
sizeof(uint8_t), 1, File);
490 fwrite(&(
Config->FontinfoId),
sizeof(
int), 1, File);
◆ WriteTempConfig()
void WriteTempConfig |
( |
FILE * |
File, |
|
|
TEMP_CONFIG |
Config |
|
) |
| |
This routine writes a binary representation of a temporary configuration to File.
- Parameters
-
File | open file to write Config to |
Config | temporary config to write to File |
- Note
- Globals: none
Definition at line 504 of file adaptive.cpp.
505 assert (
Config !=
nullptr);
508 fwrite(
Config->Protos, sizeof (uint32_t),
Config->ProtoVectorSize, File);