Nuova derivazione delle classi per la gestione del codice a livelli

git-svn-id: svn://10.65.10.50/trunk@4824 c028cbd2-c16b-5b4b-a496-9718f37d4682
This commit is contained in:
augusto 1997-07-07 10:27:25 +00:00
parent bddad2042b
commit 6a17722244

View File

@ -9,102 +9,6 @@
#endif
// **************************
// classe livelli giacenze
TMag_livelli:: TMag_livelli(const char *tabname)
{
TTable _tabformato(tabname);
int e;
_last_level=0;
e=_tabformato.first();
for (int i=0; i< MANY_MAG_LEV; i++) {
_enabled[i]=(e==NOERR);
if (_enabled[i]) {
_name[i]=_tabformato.get("S0");
_code_lenght[i]=atoi(_tabformato.get("I0"));
_picture[i]=_tabformato.get("S1");
_last_level=i+1;
} else {
_name[i]="";
_code_lenght[i]=0;
_picture[i]="";
}
e=_tabformato.next();
}
}
const bool TMag_livelli::enabled(int levnum)
{
if (levnum<=MANY_MAG_LEV && levnum>0)
return(_enabled[levnum-1]);
else
return(FALSE) ;
}
const int TMag_livelli::code_lenght(int levnum)
{
if (levnum<=MANY_MAG_LEV && levnum>0)
return(_code_lenght[levnum-1]);
else
return(0) ;
}
const int TMag_livelli::packed_lenght(int levnum)
{
int start=0;
for (int i=1; i<=levnum && levnum<=MANY_MAG_LEV; i++)
start+= _code_lenght[i-1];
return start;
}
const TString & TMag_livelli::name(int levnum)
{
if (levnum<=MANY_MAG_LEV && levnum>0)
return(_name[levnum-1]);
else
return("");
}
const TString & TMag_livelli::picture(int levnum)
{
if (levnum<=MANY_MAG_LEV && levnum>0)
return(_picture[levnum-1]);
else
return("");
}
void TMag_livelli::pack_grpcode(TString & pc, const TString &codlev, const int levnum)
{
pc.overwrite(codlev.left(_code_lenght[levnum-1]),packed_lenght(levnum-1));
}
TString TMag_livelli::unpack_grpcode(const TString & pc, const int levnum)
{
int start=0;
for (int i=1; i<levnum; i++)
start+= _code_lenght[i-1];
if (start>=pc.len())
return("");
else {
if (levnum != _last_level && !_enabled[levnum-1])
return("");
return(pc.mid(start,levnum == _last_level ? -1 : _code_lenght[levnum-1]));
}
}
TString TMag_livelli::build_tabcode(const TString & pc, const int levnum)
{
TString valore;
valore << levnum;
valore << unpack_grpcode(pc,levnum);
if (valore.len()>1)
return valore;
else
return "";
}
// *******************************
// *******************************
#define MAXSIMBOLS 256
@ -131,6 +35,13 @@ struct TAutoma_state {
bool _final;
};
// *******************************
// *******************************
// automa per il riconoscimento di metacaratteri
#define EPSILON 0
#define FIRST_STATE 1
#define FIRST_NEMPTY_SYMBOL 1
// *******************************
// *******************************
// automa per il riconoscimento di metacaratteri
@ -229,13 +140,6 @@ int TStateset::get_next()
return (-1);
}
// *******************************
// *******************************
// automa per il riconoscimento di metacaratteri
#define EPSILON 0
#define FIRST_STATE 1
#define FIRST_NEMPTY_SYMBOL 1
// labels and states
bool TR_automa::is_state(int statenum)
{
@ -476,7 +380,6 @@ bool TR_automa::recognized(const char * t_str)
}
}
// *******************************
// gestione di stringhe di metacaratteri
// *******************************
@ -486,6 +389,12 @@ bool TR_automa::recognized(const char * t_str)
#define S_LETTER 3
#define S_ANY 4
// *******************************
// *******************************
// riconoscimento di metacaratteri
class TR_automa;
bool TMetachar::recognized(const char * s)
{
return(_au->recognized(s));
@ -521,6 +430,7 @@ void TMetachar::add_tran(int s,unsigned char metasymbol, int nextstate)
}
}
// restituisce la stringa di metacaratteri del linguaggio riconosciuto
const char * TMetachar::language() const
{
@ -665,10 +575,157 @@ TMetachar::~TMetachar ()
}
// **************************************
// **************************************
// **************************************
// *** classi per il magazzino
// ***
const char *TCodice_livelli::code_format(int levnum) const
{
if (levnum<0) {
levnum=max(last_level(),1);
}
((TCodart_livelli *)this)->add_metachar(levnum);
return ((TMetachar*)_metachars.objptr(levnum-1))->language();
}
bool TCodice_livelli::fit_to_format(const char *codepart,int levnum) const
{
if (levnum<0) {
levnum=max(last_level(),1);
}
((TCodart_livelli *)this)->add_metachar(levnum);
return ((TMetachar*)_metachars.objptr(levnum-1))->recognized(codepart);
}
void TCodice_livelli::add_metachar(int levnum)
{
if (_metachars.objptr(levnum-1)==NULL)
_metachars.add(new TMetachar(picture(levnum)),levnum-1);
}
// **************************
// classe codice a livelli
TCodice_livelli:: TCodice_livelli(const char *tabname,const char *tabgrp)
{
TTable _tabformato(tabname);
int e;
_last_level=0;
e=_tabformato.first();
for (int i=0; i< MANY_MAG_LEV; i++) {
_enabled[i]=(e==NOERR);
if (_enabled[i]) {
_name[i]=_tabformato.get("S0");
_code_lenght[i]=atoi(_tabformato.get("I0"));
_picture[i]=_tabformato.get("S1");
_last_level=i+1;
} else {
_name[i]="";
_code_lenght[i]=0;
_picture[i]="";
}
e=_tabformato.next();
}
_gruppi = new TDecoder(tabgrp);
}
const bool TCodice_livelli::enabled(int levnum) const
{
if (levnum<=MANY_MAG_LEV && levnum>0)
return(_enabled[levnum-1]);
else
return(FALSE) ;
}
const int TCodice_livelli::code_lenght(int levnum) const
{
if (levnum<=MANY_MAG_LEV && levnum>0)
return(_code_lenght[levnum-1]);
else
return(0) ;
}
const int TCodice_livelli::packed_lenght(int levnum) const
{
int start=0;
for (int i=1; i<=levnum && levnum<=MANY_MAG_LEV; i++)
start+= _code_lenght[i-1];
return start;
}
const TString & TCodice_livelli::name(int levnum) const
{
if (levnum<=MANY_MAG_LEV && levnum>0)
return(_name[levnum-1]);
else
return("");
}
const TString & TCodice_livelli::picture(int levnum) const
{
if (levnum<=MANY_MAG_LEV && levnum>0)
return(_picture[levnum-1]);
else
return("");
}
void TCodice_livelli::pack_grpcode(TString & pc, const TString &codlev, const int levnum)
{
pc.overwrite(codlev.left(_code_lenght[levnum-1]),packed_lenght(levnum-1));
}
TString TCodice_livelli::unpack_grpcode(const TString & pc, const int levnum) const
{
int start=0;
for (int i=1; i<levnum; i++)
start+= _code_lenght[i-1];
if (start>=pc.len())
return("");
else {
if (levnum != _last_level && !_enabled[levnum-1])
return("");
return(pc.mid(start,levnum == _last_level ? -1 : _code_lenght[levnum-1]));
}
}
TString TCodice_livelli::build_tabcode(const TString & pc, const int levnum) const
{
TString valore;
valore << levnum;
valore << unpack_grpcode(pc,levnum);
if (valore.len()>1)
return valore;
else
return "";
}
const TString & TCodice_livelli::group_descr(const char * code, int levnum) const
{
return _gruppi->decode(build_tabcode(code,levnum));
}
TCodart_livelli ::TCodart_livelli() :
TCodice_livelli("FCA","GCA")
{
// imposta il riconoscimento dei caratteri del formato dell'ultima parte dell'articolo
TString80 format("");
TTable _tabfca("FCA");
if (_tabfca.last()==NOERR) {
format = _tabfca.get("S1");
}
_metachars.add(new TMetachar(format),max(last_level()-1,0));
}
TCodart_livelli ::~TCodart_livelli()
{
}
TCodgiac_livelli ::TCodgiac_livelli() :
TCodice_livelli("FCG","GCG")
{
}