Files correlati : db0.exe Ricompilazione Demo : [ ] Commento : Gestione interattiva distinta base git-svn-id: svn://10.65.10.50/trunk@6849 c028cbd2-c16b-5b4b-a496-9718f37d4682
259 lines
7.4 KiB
C++
Executable File
259 lines
7.4 KiB
C++
Executable File
#ifndef __DBLIB_H
|
|
#define __DBLIB_H
|
|
|
|
#ifndef __EXPR_H
|
|
#include <expr.h>
|
|
#endif
|
|
|
|
#ifndef __RECARRAY_H
|
|
#include <recarray.h>
|
|
#endif
|
|
|
|
#ifndef __TREE_H
|
|
#include <tree.h>
|
|
#endif
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TCodice_articolo
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Codice articolo di magazzino (equivale ad una TString20 )
|
|
class TCodice_articolo : public TFixed_string
|
|
{
|
|
char _str20[21];
|
|
|
|
public:
|
|
TCodice_articolo(const char* s = "") : TFixed_string(_str20, 21)
|
|
{ set(s); }
|
|
TCodice_articolo(const TString& s) : TFixed_string(_str20, 21)
|
|
{ set(s); }
|
|
TCodice_articolo(const TCodice_articolo& s) : TFixed_string(_str20, 21)
|
|
{ set(s); }
|
|
const TString& operator =(const char* s)
|
|
{ return set(s); }
|
|
const TString& operator =(const TString& s)
|
|
{ return set((const char*)s); }
|
|
const TString& operator =(const TCodice_articolo& s)
|
|
{ return set((const char*)s); }
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TCodice_um
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Codice articolo di magazzino (equivale ad una TString2 )
|
|
class TCodice_um : public TFixed_string
|
|
{
|
|
char _str2[3];
|
|
|
|
public:
|
|
TCodice_um(const char* s = "") : TFixed_string(_str2, 3)
|
|
{ set(s); }
|
|
TCodice_um(const TString& s) : TFixed_string(_str2, 3)
|
|
{ set(s); }
|
|
TCodice_um(const TCodice_um& s) : TFixed_string(_str2, 3)
|
|
{ set(s); }
|
|
const TString& operator =(const char* s)
|
|
{ return set(s); }
|
|
const TString& operator =(const TString& s)
|
|
{ return set((const char*)s); }
|
|
const TString& operator =(const TCodice_um& s)
|
|
{ return set((const char*)s); }
|
|
};
|
|
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TQuantita'
|
|
///////////////////////////////////////////////////////////
|
|
|
|
// Quantita' di un articolo in una certa unita' di misura
|
|
|
|
class TQuantita : public TSortable
|
|
{
|
|
TCodice_articolo _articolo; // Articolo di riferimento
|
|
TCodice_um _um; // Unita' di misura
|
|
real _conv; // Fattore di conversione alla base
|
|
real _val; // Valore attuale
|
|
|
|
static TDecoder* _umart1; // Decoder per trovare unita' base
|
|
static TDecoder* _umart2; // Decoder per trovare conversione
|
|
|
|
protected:
|
|
virtual int compare(const TSortable& s) const;
|
|
virtual TObject* dup() const { return new TQuantita(*this); }
|
|
|
|
void copy(const TQuantita& q);
|
|
real get_factor(const TCodice_um& um) const;
|
|
void convert(real& val, const TCodice_um& from_um, const TCodice_um& to_um) const;
|
|
|
|
public:
|
|
virtual bool ok() const { return !_um.blank(); }
|
|
|
|
const TQuantita& operator =(const TQuantita& q)
|
|
{ copy(q); return q; }
|
|
|
|
const TQuantita& operator +=(const TQuantita& q);
|
|
const TQuantita& operator -=(const TQuantita& q);
|
|
const TQuantita& operator =(const real& q);
|
|
const TQuantita& operator *=(const real& q);
|
|
const TQuantita& operator /=(const real& q);
|
|
|
|
const TCodice_articolo& articolo() const { return _articolo; }
|
|
const TCodice_um& um() const { return _um; }
|
|
const real& val() const { return _val; }
|
|
|
|
void set_articolo(const TCodice_articolo& art, const TCodice_um& um);
|
|
void set(const TCodice_articolo& art, const TCodice_um& um, const real& val)
|
|
{ set_articolo(art, um); _val = val; }
|
|
|
|
void convert_to_base();
|
|
|
|
TQuantita();
|
|
TQuantita(const TCodice_articolo& art);
|
|
TQuantita(const TCodice_articolo& art, const TCodice_um& um, const real& val);
|
|
TQuantita(const TQuantita& q);
|
|
virtual ~TQuantita();
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TDistinta_expr
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TDistinta_expr : public TExpression
|
|
{
|
|
protected:
|
|
virtual bool print_error(const char* msg) const;
|
|
|
|
public:
|
|
TDistinta_expr();
|
|
virtual ~TDistinta_expr() { }
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TDistinta_tree
|
|
///////////////////////////////////////////////////////////
|
|
|
|
class TDistinta_tree : public TBidirectional_tree
|
|
{
|
|
TCodice_articolo _root;
|
|
TToken_string _path;
|
|
int _sort, _max_depth;
|
|
|
|
TDecoder _dist, _vars, _mag, _lav;
|
|
TRecord_cache _rdist;
|
|
|
|
static const TRectype* _curr;
|
|
static TToken_string _tmp;
|
|
|
|
TStack _stack;
|
|
TAssoc_array _globals;
|
|
|
|
protected:
|
|
bool isola_codice(TString& code) const;
|
|
|
|
void add_child();
|
|
void kill_child();
|
|
const TRectype* find(const TCodice_articolo& father, int child) const;
|
|
int build_children_list(const TCodice_articolo& father, TPointer_array& child) const;
|
|
|
|
TTypeexp get_var_type(const char* var);
|
|
const TString& get_string(const char* var);
|
|
const real& get_real(const char* var);
|
|
|
|
void evaluate(TDistinta_expr& e);
|
|
real evaluate_numexpr(const char* str);
|
|
void evaluate_strexpr(const char* str, TString& res);
|
|
|
|
void push_vars();
|
|
void pop_vars();
|
|
int raggruppa(TArray& boom, int mode) const;
|
|
|
|
protected: // TTree
|
|
virtual void node2id(const TObject* node, TString& id) const;
|
|
|
|
public:
|
|
virtual bool goto_root();
|
|
virtual bool goto_firstson();
|
|
virtual bool goto_rbrother();
|
|
virtual bool goto_node(const TString &id);
|
|
virtual bool has_son() const;
|
|
virtual bool has_rbrother() const;
|
|
virtual bool has_root() const;
|
|
virtual bool has_father() const;
|
|
virtual bool has_lbrother() const;
|
|
virtual bool goto_father();
|
|
virtual bool goto_lbrother();
|
|
virtual bool get_description(TString& desc) const;
|
|
virtual TImage* image(bool selected) const;
|
|
virtual TObject* curr_node() const;
|
|
|
|
bool set_root(const TCodice_articolo& str);
|
|
long find_node(const TCodice_articolo& str, word flags = SCAN_PRE_ORDER);
|
|
|
|
void set_sort_key(int k);
|
|
int get_sort_key() const { return _sort; }
|
|
|
|
void set_max_depth(int m) { _max_depth = m; }
|
|
int get_max_depth() const { return _max_depth; }
|
|
|
|
void restart(); // reset all and go to root
|
|
int explode(TArray& boom, bool mb = FALSE, int gr = 0, int md = 0,
|
|
const char* filter = NULL, int sk = 0, bool lq = FALSE);
|
|
|
|
bool curr_code(TCodice_articolo& code) const;
|
|
bool curr_giac(TString& code) const;
|
|
int curr_comp(TString& code) const;
|
|
long curr_sort() const;
|
|
const char* curr_um(TCodice_um& code) const;
|
|
real curr_qta(bool last = FALSE) const;
|
|
int curr_depth() const { return _path.items()-1; }
|
|
|
|
bool is_cyclic(const TToken_string& path) const;
|
|
bool is_cyclic() const { return is_cyclic(_path); }
|
|
bool is_root() const;
|
|
bool is_leaf() const;
|
|
|
|
bool is_mag(const char* c = NULL) const;
|
|
bool is_lav(const char* c = NULL) const;
|
|
char get_type(const char* c = NULL) const;
|
|
|
|
void clear_globals();
|
|
void set_global(const char* var, const char* val);
|
|
void set_global(const char* var, const real& val);
|
|
|
|
TDistinta_tree();
|
|
virtual ~TDistinta_tree();
|
|
};
|
|
|
|
///////////////////////////////////////////////////////////
|
|
// TRiga_esplosione
|
|
///////////////////////////////////////////////////////////
|
|
|
|
struct TExplosion_params;
|
|
|
|
class TRiga_esplosione : public TQuantita
|
|
{
|
|
TString16 _giac;
|
|
long _sort;
|
|
int _livello;
|
|
char _tipo;
|
|
|
|
protected:
|
|
virtual TObject* dup() const { return new TRiga_esplosione(*this); }
|
|
void init(const TDistinta_tree& tree, const TExplosion_params& ep);
|
|
|
|
public:
|
|
const TString& giacenza() const { return _giac; }
|
|
long ordinamento() const { return _sort; }
|
|
int livello() const { return _livello; }
|
|
char tipo() const { return _tipo; }
|
|
|
|
TRiga_esplosione();
|
|
TRiga_esplosione(const TDistinta_tree& tree,
|
|
const TExplosion_params& ep);
|
|
TRiga_esplosione(const TRiga_esplosione& re);
|
|
virtual ~TRiga_esplosione() { }
|
|
};
|
|
|
|
#endif
|