#ifndef _DECL_tempo_H_
#define _DECL_tempo_H_
#include "charm++.h"
/* DECLS: message TempoMessage;
 */
class TempoMessage;
class CMessage_TempoMessage: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_TempoMessage() {};
    static void *pack(TempoMessage *p);
    static TempoMessage* unpack(void* p);
    static void __register(const char *s, size_t size, CkPackFnPtr pack, CkUnpackFnPtr unpack) {
      __idx = CkRegisterMsg(s, pack, unpack, 0, size);
    }
};

/* DECLS: chare TempoChare{
threaded TempoChare(void);
void tempoGeneric(TempoMessage*);
};
 */
class TempoChare;
class CProxy_TempoChare: public virtual _CK_CID{
  public:
    static int __idx;
    static void __register(const char *s, size_t size);
    CProxy_TempoChare(CkChareID __cid) { ckSetChareId(__cid); }
    CkChareID ckGetChareId(void) { return _ck_cid; }
    void ckSetChareId(CkChareID __cid) {_CHECK_CID(__cid,__idx);_ck_cid=__cid;}
/* DECLS: threaded TempoChare(void);
 */
    static void ckNew(int onPE=CK_PE_ANY);
    static void ckNew(CkChareID* pcid, int onPE=CK_PE_ANY);
    CProxy_TempoChare(int onPE=CK_PE_ANY);
    static int  __idx_TempoChare_void;
    static int  ckIdx_TempoChare(void) { return __idx_TempoChare_void; }
    static void _call_TempoChare_void(void* msg, TempoChare* obj);
    static void _callthr_TempoChare_void(CkThrCallArg *);

/* DECLS: void tempoGeneric(TempoMessage*);
 */
    void tempoGeneric(TempoMessage*msg);
    static int  __idx_tempoGeneric_TempoMessage;
    static int  ckIdx_tempoGeneric(TempoMessage*msg) { return __idx_tempoGeneric_TempoMessage; }
    static void _call_tempoGeneric_TempoMessage(void* msg, TempoChare* obj);
};

/* DECLS: group TempoGroup{
threaded TempoGroup(void);
void tempoGeneric(TempoMessage*);
};
 */
class TempoGroup;
class CProxy_TempoGroup:  public virtual _CK_GID{
  public:
    static int __idx;
    static void __register(const char *s, size_t size);
    CProxy_TempoGroup(CkGroupID _gid) { _ck_gid = _gid; _setChare(0); }
    CProxy_TempoGroup(CkChareID __cid) { ckSetChareId(__cid); }
    CkChareID ckGetChareId(void) { return _ck_cid; }
    void ckSetChareId(CkChareID __cid){_CHECK_CID(__cid,__idx);_ck_cid=__cid;_setChare(1);}
    CkGroupID ckGetGroupId(void) { return _ck_gid; }
    void ckSetGroupId(CkGroupID _gid){_ck_gid=_gid;_setChare(0);}
    TempoGroup* ckLocalBranch(void) {
      return (TempoGroup *) CkLocalBranch(_ck_gid);
    }
    static TempoGroup* ckLocalBranch(CkGroupID gID) {
      return (TempoGroup *) CkLocalBranch(gID);
    }
/* DECLS: threaded TempoGroup(void);
 */
    static CkGroupID ckNew(void);
    static CkGroupID ckNewSync(void);
    CProxy_TempoGroup(int retEP, CkChareID *cid);
    CProxy_TempoGroup(void);
    static int  __idx_TempoGroup_void;
    static int  ckIdx_TempoGroup(void) { return __idx_TempoGroup_void; }
    static void _call_TempoGroup_void(void* msg, TempoGroup* obj);
    static void _callthr_TempoGroup_void(CkThrCallArg *);

/* DECLS: void tempoGeneric(TempoMessage*);
 */
    void tempoGeneric(TempoMessage*msg){
      if(_isChare())
        CkSendMsg(__idx_tempoGeneric_TempoMessage, msg, &_ck_cid);
      else
        CkBroadcastMsgBranch(__idx_tempoGeneric_TempoMessage, msg, _ck_gid);
    }
    void tempoGeneric(TempoMessage*msg, int onPE) {
      CkSendMsgBranch(__idx_tempoGeneric_TempoMessage, msg, onPE, _ck_gid);
    }
    void tempoGeneric(TempoMessage*msg, int npes, int *pes) {
      CkSendMsgBranchMulti(__idx_tempoGeneric_TempoMessage, msg, npes, pes, _ck_gid);
    }
    static int  __idx_tempoGeneric_TempoMessage;
    static int  ckIdx_tempoGeneric(TempoMessage*msg) { return __idx_tempoGeneric_TempoMessage; }
    static void _call_tempoGeneric_TempoMessage(void* msg, TempoGroup* obj);
};

/* DECLS: array TempoArray: ArrayElement{
TempoArray(CkMigrateMessage*);
threaded TempoArray();
void tempoGeneric(TempoMessage*);
};
 */
class TempoArray;
class CProxy_TempoArray : 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_TempoArray(const CkArrayID &aid,const CkArrayIndex1D &idx)
        :CProxy_ArrayElement(aid,idx) {}
  public:
    CProxy_TempoArray(const CkArrayID &aid) 
        :CProxy_ArrayElement(aid) {}
    CProxy_TempoArray(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_TempoArray operator [] (const CkArrayIndex1D &idx) const
        {return CProxy_TempoArray(_aid, idx);}
    CProxy_TempoArray operator() (const CkArrayIndex1D &idx) const
        {return CProxy_TempoArray(_aid, idx);}
    CProxy_TempoArray operator [] (int idx) const 
        {return CProxy_TempoArray(_aid, CkArrayIndex1D(idx));}
    CProxy_TempoArray operator () (int idx) const 
        {return CProxy_TempoArray(_aid, CkArrayIndex1D(idx));}
/* DECLS: TempoArray(CkMigrateMessage*);
 */
    static int  __idx_TempoArray_CkMigrateMessage;
    static int  ckIdx_TempoArray(CkMigrateMessage*msg) { return __idx_TempoArray_CkMigrateMessage; }
    static void _call_TempoArray_CkMigrateMessage(void* msg, TempoArray* obj);

/* DECLS: threaded TempoArray(void);
 */
    static CkArrayID ckNew(int numInitial,CkGroupID mapID=_RRMapID);
    void insert(int onPE=-1);    static int  __idx_TempoArray_void;
    static int  ckIdx_TempoArray(void) { return __idx_TempoArray_void; }
    static void _call_TempoArray_void(void* msg, TempoArray* obj);
    static void _callthr_TempoArray_void(CkThrCallArg *);

/* DECLS: void tempoGeneric(TempoMessage*);
 */
    void tempoGeneric(TempoMessage*msg) const;
    static int  __idx_tempoGeneric_TempoMessage;
    static int  ckIdx_tempoGeneric(TempoMessage*msg) { return __idx_tempoGeneric_TempoMessage; }
    static void _call_tempoGeneric_TempoMessage(void* msg, TempoArray* obj);
};

extern void _registertempo(void);
#endif
