/**
 * @file
 * $Id$
 * $Revision$
 * $Author$
 * $Date$
 *
 * This file is part of The iWear Framework.
 *
 * The iWear Framework is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by the
 * Free Software Foundation as in version 2 of the License.

 * 
 * The iWear Framework is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
 * more details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * The iWear Framework; if not, write to the Free Software Foundation, Inc., 59
 * Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

#ifndef __IWREMOTE_CLASS_H
#define __IWREMOTE_CLASS_H

#include <iwremote/statement.h>
#include <iwremote/namespace.h>

namespace iwear
{
    namespace net
    {

enum derivation
{
    public_d,
    protected_d,
    private_d,
    virtual_d,
    public_virtual_d,
    protected_virtual_d,
    private_virtual_d,
};

enum classitem_type
{
    function_cit,
    declaration_cit,
    class_cit,
    enum_cit,
    num_classitem_type
};

class Class;
struct SubClass
{
private:
protected:
public:
    SubClass( const string& d, const string& );
    SubClass( derivation d_t_, Class* d_class_ ) : d_t(d_t_), d_class(d_class_) { }
    // Use this only for temporary parser please
    string class_id;
    derivation d_t;
    Class* d_class;
};

enum protection
{
    public_t,
    protected_t,
    private_t,
    num_protection
};

class Class;
class ClassItem: public virtual Statement
{
public:
    ClassItem( const string& _id ) : crcid(0),
	id(_id), prot(public_t), my_class(0) { }
    virtual ~ClassItem() { }
    virtual string get_crcstring(void) = 0;
    virtual void generate_crcids( const string& ) = 0;
    string crcs;
    uint32_t crcid;
    string id;
    protection prot;
    virtual classitem_type get_classitem_type( void ) = 0;
    Class* my_class;
};

class Class : public NamespaceItem, public ClassItem
{
private:
protected:
public:
    list<string> adapters;
    list<ClassItem*> items;
    list<SubClass> subclasses;
    Class( const string& _id) : ClassItem(_id), version_id(0),
				has_variables(false), has_functions(false) { }
    Class( const string& _id, uint32_t v) : ClassItem(_id), version_id(v),
				has_variables(false), has_functions(false) { }

    uint32_t version_id;

    string data_size;

    bool has_variables;

    bool has_functions;

    bool adapt_private;

    void add_item( ClassItem& st );

    void add_subclass( const SubClass& sc ) { subclasses.push_back(sc); }

    /**
     * Generates the crcids of the class and of all its functions.
     */
    virtual void generate_crcids( const string& );
    virtual string get_crcstring( );
    virtual nit_type get_namespaceitem_type( void ) { return class_t; }
    virtual classitem_type get_classitem_type( void ) { return class_cit; }

    void generate_own_size( void );
    virtual string get_own_size( void ) { return data_size; }
};

}
}
#endif
