// -*- C++ -*- // (c) COPYRIGHT URI/MIT 1994-1998 // Please read the full copyright statement in the file COPYRIGHT. // // Authors: // jhrg,jimg James Gallagher (jgallagher@gso.uri.edu) // reza Reza Nekovei (reza@intcomm.net) // This file contains the interface definition for the class Connections, // which manages a set of Connect objects. Once created, a Connect * can be // added (managed) and refferred to by an integer. The int can also be used // to delete the Connect *. // // This class should become a mapping between (Connect *)s and some other // type -- the type normally used by an API to refer to one of its // objects/files. For netcdf and JGOFS, int will do just fine, but other APIs // (HDF ?) use pointers. // // jhrg 9/30/94 /* * $Log: Connections.h,v $ * Revision 1.6 1999/05/04 19:47:20 jimg * Fixed copyright statements. Removed more of the GNU classes. * * Revision 1.5 1998/02/04 14:55:31 tom * Another draft of documentation. * * Revision 1.4 1997/08/11 18:19:13 jimg * Fixed comment leaders for new CVS version * * Revision 1.3 1996/06/08 00:19:46 jimg * Added config_dap.h in place of config_netio.h * * Revision 1.2 1996/05/31 23:29:33 jimg * Updated copyright notice. * * Revision 1.1 1995/01/10 16:23:06 jimg * Created new `common code' library for the net I/O stuff. * * Revision 1.3 1994/11/18 21:12:20 reza * Changed it to a template class for derived classes of the Connect * * Revision 1.2 1994/10/05 20:23:29 jimg * Fixed errors in *.h files comments - CVS bites again. * Changed request_{das,dds} so that they use the field `_api_name' * instead of requiring callers to pass the api name. * * Revision 1.1 1994/10/05 18:02:11 jimg * First version of the connection management classes. * This commit also includes early versions of the test code. */ #ifndef _connections_h #define _connections_h #ifdef __GNUG__ #pragma interface #endif #include #include "config_dap.h" #include "Connect.h" const int MAX_CONNECTIONS = 64; /** This object holds a collection of Connect objects. It contains methods to add and delete Connect objects from the collection, and defines the index operator ([]) to retrieve individual objects. @memo Holds a collection of Connect objects. @see Connect */ template class Connections { private: int _max_con; SLList _free; // free list of connections T *_conns; // array alloc'd at object construction void init_array(int i); public: /** The constructor for the Connections object. @param max_connections The maximum number of open Connect objects this Connections object can hold. This number should not be bigger than the #MAX_CONNECTIONS# parameter in the Connections header file. */ Connections(int max_connections = MAX_CONNECTIONS); /** The specialized copy constructor. */ Connections(const Connections &cs); ~Connections(); Connections &operator=(const Connections &rhs); /** This operator is how you retrieve Connect objects from the Connection collection. @memo Indexing operator. @return This function returns a reference to an element of the Connections array. It returns a reference so that this operator will work on both the left and right side of the assignment operator. */ T &operator[](int i); /** Add a Connect object to the array. @return The index of the newly added Connect object. @param c The Connect object to add to the array. */ int add_connect(T c); /** Delete a Connect object from the array. @param i The integer index of the object to remove from the array. */ void del_connect(int i); }; #endif // _connections_h