--- parser3/src/classes/classes.h 2002/08/01 11:26:43 1.20 +++ parser3/src/classes/classes.h 2026/04/25 13:38:46 1.48 @@ -1,13 +1,16 @@ /** @file Parser: @b Methoded class decl. - Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexandr Petrosian (http://paf.design.ru) + Copyright (c) 2001-2026 Art. Lebedev Studio (https://www.artlebedev.com) + Authors: Konstantin Morshnev , Alexandr Petrosian */ + #ifndef CLASSES_H #define CLASSES_H -static const char* IDENT_CLASSES_H="$Id: classes.h,v 1.20 2002/08/01 11:26:43 paf Exp $"; +#define IDENT_CLASSES_H "$Id: classes.h,v 1.48 2026/04/25 13:38:46 moko Exp $" + +// include #include "pa_vstateless_class.h" #include "pa_array.h" @@ -15,7 +18,11 @@ static const char* IDENT_CLASSES_H="$Id: /** Pure virtual base for configurable Methoded descendants @see Methoded_array */ -class Methoded : public VStateless_class { +class Methoded: public VStateless_class { +public: // Value + + override const char* type() const { return ftype; } + public: // Methoded /** should Methoded_array::register_directly_used register this class in @@ -23,28 +30,26 @@ public: // Methoded if not - global variable with Methoded descendant is used in VStateless_class parameter */ - virtual bool used_directly() =0; + virtual bool used_directly() { return true; } /// use this method to read parameters from root "auto.p"; access r.main_class virtual void configure_admin(Request& ) {} - /// use this method to read parameters from 'MAIN' class; access r.main_class - virtual void configure_user(Request& ) {} - /// use it to construct static variables. check some static so that would be only ONCE! - virtual void construct_statics() {} + +private: + + const char* ftype; public: // usage - Methoded(Pool& apool, const char *aname, VStateless_class *abase=0) : - VStateless_class(apool, new(apool) String(apool, aname), abase) { - } + Methoded(const char* atype): ftype(atype){} void register_directly_used(Request& r); }; /// all Methoded registered here in autogenerated classes.C -class Methoded_array : public Array { +class Methoded_array: public Array { public: - Methoded_array(Pool& pool); + Methoded_array(); public: // Methoded for_each-es /// @see Methoded::configure_admin @@ -55,7 +60,18 @@ public: // Methoded for_each-es void register_directly_used(Request& r); }; -extern Methoded_array *methoded_array; -void init_methoded_array(Pool& pool); +// globals + +Methoded_array& methoded_array(); + +// defines + +#define DECLARE_CLASS_VAR(name, self) \ + Methoded* name##_class=NULL; \ + Methoded* name##_instance(){ if(!name##_class){ name##_class=self; } return name##_class; } + +#define ADD_CLASS_VAR(name) \ + Methoded* name##_instance(); \ + *this+=name##_instance(); #endif