OwnerBox< Owner, Data > Class Template Reference

#include <OwnerBox.h>

List of all members.

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.

00022                                            :
00023       bid(-1), type(-1),
00024       owner(o), callback(fn), data(0),
00025       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.

00027                                                          :
00028       bid(id), type(tp),
00029       owner(o), callback(fn), data(0),
00030       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.

00033                     {
00034       if (numberUsers) {
00035         CkPrintf("OwnerBox::~OwnerBox() - still have boxes out there!\n");
00036       }
00037     }


Member Function Documentation

template<class Owner, class Data>
void OwnerBox< Owner, Data >::checkIn ( Box< Owner, Data > *  box  )  [inline]

Definition at line 101 of file OwnerBox.h.

References OwnerBox< Owner, Data >::clientRemove().

Referenced by Patch::unregisterAvgPositionPickup(), Patch::unregisterForceDeposit(), Patch::unregisterLcpoTypePickup(), Patch::unregisterPositionPickup(), and Patch::unregisterVelocityPickup().

00101                                                                {
00102   delete box;
00103   clientRemove();
00104 }

template<class Owner, class Data>
Box< Owner, Data > * OwnerBox< Owner, Data >::checkOut ( int  id  )  [inline]

Definition at line 82 of file OwnerBox.h.

References OwnerBox< Owner, Data >::clientAdd().

Referenced by Patch::registerAvgPositionPickup(), Patch::registerForceDeposit(), Patch::registerLcpoTypePickup(), Patch::registerPositionPickup(), and Patch::registerVelocityPickup().

00082                                                              {
00083   clientAdd();
00084   return (new Box<Owner,Data>(this,id));
00085 }

template<class Owner, class Data>
void OwnerBox< Owner, Data >::clientAdd (  )  [inline]

Definition at line 74 of file OwnerBox.h.

Referenced by OwnerBox< Owner, Data >::checkOut(), and HomePatch::registerProxy().

00074                                                 {
00075   if (closeCount != numberUsers || openCount != numberUsers) {
00076     CkPrintf("OwnerBox::clientAdd() while in use\n");
00077   }
00078   ++numberUsers; ++closeCount; ++openCount; 
00079 }

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().

00062                                   {
00063       if ( ! (closeCount -= count) ) close();
00064     }

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().

00058                                   {
00059       openCount -= count;
00060       return data;
00061     }

template<class Owner, class Data>
void OwnerBox< Owner, Data >::clientRemove (  )  [inline]

Definition at line 88 of file OwnerBox.h.

Referenced by OwnerBox< Owner, Data >::checkIn(), and HomePatch::unregisterProxy().

00088                                                {
00089   if (closeCount != numberUsers || openCount != numberUsers) {
00090     CkPrintf("OwnerBox::clientRemove() while in use\n");
00091   }
00092   if ( ! numberUsers-- ) {
00093     CkPrintf("OwnerBox::clientRemove() - no registrants remaining\n");
00094     numberUsers = 0;
00095   } else {
00096     closeCount--; openCount--;
00097   }
00098 }

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().

00107                                             {
00108   if (!closeCount && !openCount) {
00109     data = 0; closeCount = openCount = numberUsers;
00110     (owner->*callback)();
00111   } else {
00112     CkPrintf("OwnerBox::close() - close called, but closeCount %d openCount %d\n", closeCount, openCount);
00113   }
00114 }

template<class Owner, class Data>
int OwnerBox< Owner, Data >::isOpen (  )  [inline]

Definition at line 51 of file OwnerBox.h.

00051                  {
00052       return (closeCount != numberUsers || openCount != numberUsers);
00053     }

template<class Owner, class Data>
void OwnerBox< Owner, Data >::open ( Data *  d  )  [inline]

Definition at line 39 of file OwnerBox.h.

00039                        {
00040       closeCount = openCount = numberUsers;
00041       data = d;
00042       if ( ! closeCount ) close();
00043     }


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:
Generated on Sun Sep 24 01:17:19 2017 for NAMD by  doxygen 1.4.7