Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > help in designing class

Reply
Thread Tools

help in designing class

 
 
Naren
Guest
Posts: n/a
 
      05-25-2004
Hello All,
I am presently designing a cleint server architecture.
I require some suggestions and help by the experts here.

MyServer class conatins a list of Mysock class.

class Myserver
{
private:
list<Mysock> L1;
};

MySock is a class containing the socket information

class MySock
{
private:
int _socketdesc;
Type *pType;
};

Type is a class which conatins the device type and an ID of the device
which connects to the server

class Type
{
private:
eType e;
int ID;
};

Now when a command has to be sent to some device. I get its ID, eType
and the command.
This has to be sent to the unique device.

SO here you see that I have to do a linear search for the correct
device to send the command.

The type class is filled by the Mysock class after recieving the first
packet containing the information. so a type object is created by the
Mysock class.

Now if Myserver had a list of Newtype
class Newtype
{
private:
etype e;
list<NewID> L;
};

class NewID
{
private:
int ID;
int _socketdesc;
};

This helps in searching the device fast but since type information is
obtained after recieving the first paket I am not able to use this
approach.

Could anyone help me?

Thanks in advance.

Regards,
Naren.
 
Reply With Quote
 
 
 
 
Victor Bazarov
Guest
Posts: n/a
 
      05-25-2004
Naren wrote:
> MyServer class conatins a list of Mysock class.
>
> class Myserver
> {
> private:
> list<Mysock> L1;
> };
>
> MySock is a class containing the socket information
>
> class MySock
> {
> private:
> int _socketdesc;
> Type *pType;
> };
>
> Type is a class which conatins the device type and an ID of the device
> which connects to the server
>
> class Type
> {
> private:
> eType e;
> int ID;
> };
>
> Now when a command has to be sent to some device. I get its ID, eType


How does the server know what combination of 'ID' and 'eType' to use?

> and the command.
> This has to be sent to the unique device.


What if there is no such "device" connected?

>
> SO here you see that I have to do a linear search for the correct
> device to send the command.


It doesn't have to be linear. You could cache the information in, say,
a map<>, it would speed up the search. Or you could simply keep the
list of your 'Mysock' objects _sorted_. That should speed up the search
too.

>
> The type class is filled by the Mysock class


Don't you mean "the Type class"?

> after recieving the first
> packet containing the information. so a type object is created by the


Don't you mean "a Type object"?

> Mysock class.
>
> Now if Myserver had a list of Newtype
> class Newtype
> {
> private:
> etype e;


What's "etype"? Is it the same as "eType"?

> list<NewID> L;


What's the meaning of a list of IDs in the "Newtype"?

> };
>
> class NewID
> {
> private:
> int ID;
> int _socketdesc;
> };
>
> This helps in searching the device fast but since type information is
> obtained after recieving the first paket I am not able to use this
> approach.


Why not?

>
> Could anyone help me?


Sure. As soon as you explain what you expect us to help you with.

Designing a type or types requires understanding of the problem that
you're trying to solve. You showed us some implementation details,
which even according to you don't do the job, and you think we can
figure it out what you want, from them? You give our mind-reading
ability way too much credit.

Now, let's just reiterate what you said, and we can probably get to
mutual understanding a bit sooner.

- A connection is established by the client, and never by the server.
Or is that not so?

- Once a connection is established, its parameters (ID and eType) are
figured out. Or not. You didn't say how ID is assigned.

- To communicate to clients, the server sends commands identified by
command ID, and 'Type'. How does the server know what 'Type' to
use?

You see, perhaps you need to state your problem just a bit clearer...

V
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
Help Help!!! In designing ASP.NET Interactive/ Calculative Application. Dilip Bajaj via .NET 247 ASP .Net 2 03-21-2005 04:42 PM
help in designing class Naren C++ 1 05-26-2004 01:54 PM
Questions of designing a class alexhong2001 C++ 3 02-18-2004 11:20 PM
Designing a Volume Class E G C++ 6 01-23-2004 06:19 AM



Advertisments