Annotation of parser3/src/types/pa_vtable.h, revision 1.27

1.6       paf         1: /** @file
1.15      paf         2:        Parser: @b table parser class decl.
1.6       paf         3: 
1.1       paf         4:        Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.6       paf         5: 
1.1       paf         6:        Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
                      7: 
1.27    ! parser      8:        $Id: pa_vtable.h,v 1.26 2001/06/27 12:44:33 parser Exp $
1.1       paf         9: */
                     10: 
                     11: #ifndef PA_VTABLE_H
                     12: #define PA_VTABLE_H
                     13: 
                     14: #include "pa_vstateless_object.h"
                     15: #include "pa_table.h"
1.26      parser     16: #include "pa_vvoid.h"
1.1       paf        17: 
1.27    ! parser     18: #define TABLE_FIELDS_ELEMENT_NAME "fields"
        !            19: 
1.16      paf        20: extern Methoded *table_class;
                     21: 
1.6       paf        22: /// value of type 'table'. implemented with Table
1.1       paf        23: class VTable : public VStateless_object {
                     24: public: // Value
                     25: 
                     26:        const char *type() const { return "table"; }
1.6       paf        27:        /// extract VTable
1.10      paf        28:        Table *get_table() { return ftable; }
1.18      paf        29:        /// VTable: columns,methods
1.27    ! parser     30:        Value *get_element(const String& name);
1.7       paf        31: 
                     32: protected: // VAliased
                     33: 
1.9       paf        34:        /// disable .CLASS element. @see VAliased::get_element
1.13      paf        35:        bool hide_class() { return true; }
1.1       paf        36: 
                     37: public: // usage
                     38: 
1.12      paf        39:        VTable(Pool& apool, Table* atable=0) : VStateless_object(apool, *table_class), 
1.21      paf        40:                ftable(atable), locked(false) {
1.1       paf        41:        }
1.16      paf        42:        void lock() { 
                     43:                check_lock();
                     44:                locked=true; 
                     45:        }
1.14      paf        46:        void unlock() { locked=false; }
                     47:        void set_table(Table& avalue) { 
1.16      paf        48:                check_lock();
1.14      paf        49:                ftable=&avalue; 
                     50:        }
1.1       paf        51:        Table& table() { 
1.4       paf        52:                if(!ftable)
1.1       paf        53:                        bark("getting unset vtable value");
                     54: 
1.4       paf        55:                return *ftable; 
1.1       paf        56:        }
                     57: 
                     58: private:
1.27    ! parser     59: 
        !            60:        Value *fields_element();
1.1       paf        61: 
1.16      paf        62:        void check_lock() {
                     63:                if(locked)
                     64:                        bark("is locked");
                     65:        }
1.18      paf        66: 
                     67: private:
                     68: 
                     69:        Table *ftable;
                     70:        bool locked;
1.1       paf        71: 
                     72: };
                     73: 
                     74: #endif

E-mail: