468,119 Members | 1,911 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,119 developers. It's quick & easy.

How to represent a chunk of Constant Data

In my application I have a Connection class which has, amongst others,
attributes which represent a host id and port number. These must be unique
for each Connection. I want these attributes to be initialised to values
given by the constructor's parameters. I know in advance how many Connection
classes I need and what the values of these attributes will be. The
Connection class instances are created at various points during the
intialisation phase of the application. I want to hold, in one place, all
the possible values of host id and port number that the application can use.
This way, whenever the need for another Connection instance arises, a new
value can just be added to the list. I was thinking of a ConnectionDetails
class could do this but I'm not sure how best to implement it. It may be
that it will just contain constant data or enums. I don't want to have a
header file full of #defines that I include all over the place. Can anyone
help?
Jul 19 '05 #1
1 1613
AdamJoe1 wrote:
In my application I have a Connection class which has, amongst others,
attributes which represent a host id and port number. These must be unique
for each Connection. I want these attributes to be initialised to values
given by the constructor's parameters. I know in advance how many Connection
classes I need and what the values of these attributes will be. The
Connection class instances are created at various points during the
intialisation phase of the application. I want to hold, in one place, all
the possible values of host id and port number that the application can use.
This way, whenever the need for another Connection instance arises, a new
value can just be added to the list. I was thinking of a ConnectionDetails
class could do this but I'm not sure how best to implement it. It may be
that it will just contain constant data or enums. I don't want to have a
header file full of #defines that I include all over the place. Can anyone
help?


Perhaps you want to hold unused Connection instances in a freelist. This
way, you can create the Connections (all at once?) in one place, and you
don't have to worry about spreading the various Connection attribute
details around your code. You just ask for the next available Connection.

/david

--
"As a scientist, Throckmorton knew that if he were ever to break wind in
the echo chamber, he would never hear the end of it."

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by bartek | last post: by
3 posts views Thread by Eric Anderson Vianet SAO | last post: by
22 posts views Thread by Fred Ma | last post: by
29 posts views Thread by fdmfdmfdm | last post: by
3 posts views Thread by Willy Stevens | last post: by
7 posts views Thread by Hendrik Schober | last post: by
16 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.