#ifndef MPARLIST_H
#define MPARLIST_H

/////////////////////////////////////////////////////////////////////////////
//                                                                         //
// MParList                                                                //
//                                                                         //
// List of parameter containers (MParContainer)                            //
//                                                                         //
/////////////////////////////////////////////////////////////////////////////

#ifndef MAGIC_H
#include "MAGIC.h"
#endif

#ifndef ROOT_TObjArray
#include <TObjArray.h>
#endif
#ifndef MPARCONTAINER_H
#include "MParContainer.h"
#endif

class TOrdCollection;

class MLog;

class MParList : public MParContainer
{
private:
    TOrdCollection *fContainer;	// Collection of Parameter and Data Containers
    TOrdCollection *fAutodelete; // All what this list contains is deleted in the destructor

    static TString GetClassName(const char *classname);
    static TString GetObjectName(const char *classname, const char *objname);

    enum { kIsOwner = BIT(14) };

public:
    MParList(const char *name=NULL, const char *title=NULL);
    MParList(MParList &ts);

    ~MParList();

    Bool_t AddToList(MParContainer *obj, MParContainer *where = NULL);
    void   AddToList(TObjArray *list);

    void SetLogStream(MLog *log);

    TObject       *FindObject(const char *name) const;
    TObject       *FindObject(TObject *obj) const;
    MParContainer *FindCreateObj(const char *classname, const char *objname=NULL);

    TObjArray FindObjectList(const char *name, UInt_t first, const UInt_t last) const;
    TObjArray FindObjectList(const char *name, const UInt_t num) const
    {
        return FindObjectList(name, 0, num);
    }

    TObjArray FindCreateObjList(const char *cname, UInt_t first, const UInt_t last, const char *oname=NULL);
    TObjArray FindCreateObjList(const char *cname, const UInt_t num, const char *oname=NULL)
    {
        return FindCreateObjList(cname, 0, num, oname);
    }

    static TObjArray CreateObjList(const char *cname, UInt_t first, const UInt_t last, const char *oname=NULL);
    static TObjArray CreateObjList(const char *cname, const UInt_t num, const char *oname=NULL)
    {
        return CreateObjList(cname, 0, num, oname);
    }

    void Reset();
    void SetReadyToSave(Bool_t flag=kTRUE);

    void SetOwner(Bool_t enable=kTRUE);

    void Print(Option_t *t = NULL) const;

    ClassDef(MParList, 0) // list of parameter containers (MParContainer)
};

#endif
