#ifndef _DECL_ampi_H_
#define _DECL_ampi_H_
#include "charm++.h"
#include "MetisLB.decl.h"

/* DECLS: message ArgsInfo;
 */
class ArgsInfo;
class CMessage_ArgsInfo:public CkArrayMessage{
  public:
    static int __idx;
    void* operator new(size_t, const int);
    void* operator new(size_t);
    void operator delete(void *p){CkFreeMsg(p);}
    void* operator new(size_t, void*p) {return p;}
    void* operator new(size_t, int*, const int);
    void* operator new(size_t, int*);
    static void*alloc(int,size_t,int*,int);
    CMessage_ArgsInfo() {};
    static void *pack(ArgsInfo *p);
    static ArgsInfo* unpack(void* p);
    static void __register(const char *s, size_t size, CkPackFnPtr pack, CkUnpackFnPtr unpack) {
      __idx = CkRegisterMsg(s, pack, unpack, 0, size);
    }
};

/* DECLS: message AmpiMsg;
 */
class AmpiMsg;
class CMessage_AmpiMsg:public CkArrayMessage{
  public:
    static int __idx;
    void* operator new(size_t, const int);
    void* operator new(size_t);
    void operator delete(void *p){CkFreeMsg(p);}
    void* operator new(size_t, void*p) {return p;}
    void* operator new(size_t, int*, const int);
    void* operator new(size_t, int*);
    static void*alloc(int,size_t,int*,int);
    CMessage_AmpiMsg() {};
    static void *pack(AmpiMsg *p);
    static AmpiMsg* unpack(void* p);
    static void __register(const char *s, size_t size, CkPackFnPtr pack, CkUnpackFnPtr unpack) {
      __idx = CkRegisterMsg(s, pack, unpack, 0, size);
    }
};

/* DECLS: message AmpiStartMsg;
 */
class AmpiStartMsg;
class CMessage_AmpiStartMsg:public CkArrayMessage{
  public:
    static int __idx;
    void* operator new(size_t, const int);
    void* operator new(size_t);
    void operator delete(void *p){CkFreeMsg(p);}
    void* operator new(size_t, void*p) {return p;}
    void* operator new(size_t, int*, const int);
    void* operator new(size_t, int*);
    static void*alloc(int,size_t,int*,int);
    CMessage_AmpiStartMsg() {};
    static void *pack(AmpiStartMsg *p);
    static AmpiStartMsg* unpack(void* p);
    static void __register(const char *s, size_t size, CkPackFnPtr pack, CkUnpackFnPtr unpack) {
      __idx = CkRegisterMsg(s, pack, unpack, 0, size);
    }
};

/* DECLS: array ampi: ArrayElement{
ampi(CkMigrateMessage*);
ampi(AmpiStartMsg*);
void generic(AmpiMsg*);
threaded void run(ArgsInfo*);
threaded void run(void);
void migrate(void);
};
 */
class ampi;
class CProxy_ampi : public CProxy_ArrayElement{
  public:
    static int __idx;
    static void __register(const char *s, size_t size);
    static CkGroupID buildArrayGroup(CkGroupID mapID=_RRMapID,int numInitial=0)
    {
        return CkArray::CreateArray(mapID,numInitial);
    }
    static CkGroupID buildArrayGroup(int ctorIndex,int numInitial,CkGroupID mapID,
            CkArrayMessage *msg)
    {
        CkGroupID id=buildArrayGroup(mapID,numInitial);
        CProxy_CkArrayBase(id).base_insert1D(ctorIndex,numInitial,msg);
        return id;
    }
  protected:
    CProxy_ampi(const CkArrayID &aid,const CkArrayIndex1D &idx)
        :CProxy_ArrayElement(aid,idx) {}
  public:
    CProxy_ampi(const CkArrayID &aid) 
        :CProxy_ArrayElement(aid) {}
    CProxy_ampi(void) {}
    static CkArrayID ckNew(void) {return CkArrayID(buildArrayGroup());}
    static CkArrayID ckNew_mapped(CkGroupID mapID) {return CkArrayID(buildArrayGroup(mapID));}
//Generalized array indexing: (these KEEP the index you pass in!)
    CProxy_ampi operator [] (const CkArrayIndex1D &idx) const
        {return CProxy_ampi(_aid, idx);}
    CProxy_ampi operator() (const CkArrayIndex1D &idx) const
        {return CProxy_ampi(_aid, idx);}
    CProxy_ampi operator [] (int idx) const 
        {return CProxy_ampi(_aid, CkArrayIndex1D(idx));}
    CProxy_ampi operator () (int idx) const 
        {return CProxy_ampi(_aid, CkArrayIndex1D(idx));}
/* DECLS: ampi(CkMigrateMessage*);
 */
    static int  __idx_ampi_CkMigrateMessage;
    static int  ckIdx_ampi(CkMigrateMessage*msg) { return __idx_ampi_CkMigrateMessage; }
    static void _call_ampi_CkMigrateMessage(void* msg, ampi* obj);

/* DECLS: ampi(AmpiStartMsg*);
 */
    static CkArrayID ckNew(AmpiStartMsg*msg, int numInitial,CkGroupID mapID=_RRMapID);
    void insert(AmpiStartMsg*msg, int onPE=-1);    static int  __idx_ampi_AmpiStartMsg;
    static int  ckIdx_ampi(AmpiStartMsg*msg) { return __idx_ampi_AmpiStartMsg; }
    static void _call_ampi_AmpiStartMsg(void* msg, ampi* obj);

/* DECLS: void generic(AmpiMsg*);
 */
    void generic(AmpiMsg*msg) const;
    static int  __idx_generic_AmpiMsg;
    static int  ckIdx_generic(AmpiMsg*msg) { return __idx_generic_AmpiMsg; }
    static void _call_generic_AmpiMsg(void* msg, ampi* obj);

/* DECLS: threaded void run(ArgsInfo*);
 */
    void run(ArgsInfo*msg) const;
    static int  __idx_run_ArgsInfo;
    static int  ckIdx_run(ArgsInfo*msg) { return __idx_run_ArgsInfo; }
    static void _call_run_ArgsInfo(void* msg, ampi* obj);
    static void _callthr_run_ArgsInfo(CkThrCallArg *);

/* DECLS: threaded void run(void);
 */
    void run(void) const;
    static int  __idx_run_void;
    static int  ckIdx_run(void) { return __idx_run_void; }
    static void _call_run_void(void* msg, ampi* obj);
    static void _callthr_run_void(CkThrCallArg *);

/* DECLS: void migrate(void);
 */
    void migrate(void) const;
    static int  __idx_migrate_void;
    static int  ckIdx_migrate(void) { return __idx_migrate_void; }
    static void _call_migrate_void(void* msg, ampi* obj);
};

extern void _registerampi(void);
#endif
