473,382 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

help in designing class

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.
Jul 22 '05 #1
1 1601
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
Jul 22 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: E G | last post by:
Hi! I am having problems in designing a class. First, I have a base class that allocates a 3D data set and allows some other mathematical operations with it, something like this: template...
3
by: alexhong2001 | last post by:
When design a class, should always make it "derivable" as a base class? Is there really a situation that the designed class not "derivable"? When should make a member "protected"? Only when...
1
by: Naren | last post by:
Victor Bazarov <v.Abazarov@comAcast.net> wrote: >Naren wrote: >> MyServer class conatins a list of Mysock class. >> >> class Myserver >> { >> private: >> list<Mysock> L1; >> }; >>
12
by: James Brown | last post by:
Hi all, Having problems designing a template-class. I'll describe my scenario first then show what I've come up with so far: Need a class to provide pointer/array-like access to an area of...
13
by: Charulatha Kalluri | last post by:
Hi, I'm implementing a Matrix class, as part of a project. This is the interface I've designed: class Matrix( )
2
by: Jackson Yap | last post by:
can someone kind enough to help me look at the attached html and js file? Why is it that the javascript menu could not work at www.apchosting.net but could work at...
2
by: sck10 | last post by:
Hello, I created a class (public class General) with the following. My question is, is this good practice to have a group of methods(?) in one class, or should I have a separate class for each...
4
by: Andrew Taylor | last post by:
Hi, I've been using PHP for a long time, I have designed and developed a number of mid-range systems. I've always used a procedural approach. I fully understand the concept of OO, I know all the...
30
by: Alf P. Steinbach | last post by:
I once suggested in that SomeOne Else(TM) should propose a string value class that accepted literals and char pointers and so on, with possible custom deleter, and in case of literal strings just...
7
by: praveenb000 | last post by:
Hi, every one on this forum.... I am new to web designing (using HTML/CSS). i designed a web page using HTML, Css with dream weaver. Here is the code i used for the desinging. it appears well...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.