NAMD
Public Member Functions | Friends | List of all members
OwnerBox< Owner, Data > Class Template Reference

#include <OwnerBox.h>

Public Member Functions

 OwnerBox (Owner *o, void(Owner::*fn)())
 
 OwnerBox (Owner *o, void(Owner::*fn)(), int id, int tp)
 
 ~OwnerBox (void)
 
void open (Data *d)
 
void close (void)
 
Box< Owner, Data > * checkOut (int id)
 
void checkIn (Box< Owner, Data > *box)
 
int isOpen ()
 
void clientAdd ()
 
void clientRemove ()
 
Data * clientOpen (int count=1)
 
void clientClose (int count=1)
 

Friends

class Box< Owner, Data >
 

Detailed Description

template<class Owner, class Data>
class OwnerBox< Owner, Data >

Definition at line 14 of file OwnerBox.h.

Constructor & Destructor Documentation

template<class Owner, class Data>
OwnerBox< Owner, Data >::OwnerBox ( Owner *  o,
void(Owner::*)()  fn 
)
inline

Definition at line 22 of file OwnerBox.h.

22  :
23  bid(-1), type(-1),
24  owner(o), callback(fn), data(0),
25  numberUsers(0), openCount(0), closeCount(0) {};
template<class Owner, class Data>
OwnerBox< Owner, Data >::OwnerBox ( Owner *  o,
void(Owner::*)()  fn,
int  id,
int  tp 
)
inline

Definition at line 27 of file OwnerBox.h.

27  :
28  bid(id), type(tp),
29  owner(o), callback(fn), data(0),
30  numberUsers(0), openCount(0), closeCount(0) {};
template<class Owner, class Data>
OwnerBox< Owner, Data >::~OwnerBox ( void  )
inline

Definition at line 33 of file OwnerBox.h.

33  {
34  if (numberUsers) {
35  CkPrintf("OwnerBox::~OwnerBox() - still have boxes out there!\n");
36  }
37  }

Member Function Documentation

template<class Owner, class Data>
void OwnerBox< Owner, Data >::checkIn ( Box< Owner, Data > *  box)
inline
template<class Owner , class Data >
Box< Owner, Data > * OwnerBox< Owner, Data >::checkOut ( int  id)
inline
template<class Owner , class Data >
void OwnerBox< Owner, Data >::clientAdd ( void  )
inline

Definition at line 74 of file OwnerBox.h.

Referenced by HomePatch::registerProxy().

74  {
75  if (closeCount != numberUsers || openCount != numberUsers) {
76  CkPrintf("OwnerBox::clientAdd() while in use\n");
77  }
78  ++numberUsers; ++closeCount; ++openCount;
79 }
template<class Owner, class Data>
void OwnerBox< Owner, Data >::clientClose ( int  count = 1)
inline

Definition at line 62 of file OwnerBox.h.

Referenced by HomePatch::receiveResults().

62  {
63  if ( ! (closeCount -= count) ) close();
64  }
void close(void)
Definition: OwnerBox.h:107
template<class Owner, class Data>
Data* OwnerBox< Owner, Data >::clientOpen ( int  count = 1)
inline

Definition at line 58 of file OwnerBox.h.

Referenced by HomePatch::receiveResults().

58  {
59  openCount -= count;
60  return data;
61  }
template<class Owner , class Data >
void OwnerBox< Owner, Data >::clientRemove ( )
inline

Definition at line 88 of file OwnerBox.h.

Referenced by HomePatch::unregisterProxy().

88  {
89  if (closeCount != numberUsers || openCount != numberUsers) {
90  CkPrintf("OwnerBox::clientRemove() while in use\n");
91  }
92  if ( ! numberUsers-- ) {
93  CkPrintf("OwnerBox::clientRemove() - no registrants remaining\n");
94  numberUsers = 0;
95  } else {
96  closeCount--; openCount--;
97  }
98 }
template<class Owner , class Data >
void OwnerBox< Owner, Data >::close ( void  )
inline

Definition at line 107 of file OwnerBox.h.

Referenced by OwnerBox< Patch, CompAtom >::clientClose(), and OwnerBox< Patch, CompAtom >::open().

107  {
108  if (!closeCount && !openCount) {
109  data = 0; closeCount = openCount = numberUsers;
110  (owner->*callback)();
111  } else {
112  CkPrintf("OwnerBox::close() - close called, but closeCount %d openCount %d\n", closeCount, openCount);
113  }
114 }
template<class Owner, class Data>
int OwnerBox< Owner, Data >::isOpen ( )
inline

Definition at line 51 of file OwnerBox.h.

Referenced by HomePatch::boxClosed().

51  {
52  return (closeCount != numberUsers || openCount != numberUsers);
53  }
template<class Owner, class Data>
void OwnerBox< Owner, Data >::open ( Data *  d)
inline

Definition at line 39 of file OwnerBox.h.

Referenced by Patch::positionsReady().

39  {
40  closeCount = openCount = numberUsers;
41  data = d;
42  if ( ! closeCount ) close();
43  }
void close(void)
Definition: OwnerBox.h:107

Friends And Related Function Documentation

template<class Owner, class Data>
friend class Box< Owner, Data >
friend

Definition at line 16 of file OwnerBox.h.


The documentation for this class was generated from the following file: