473,396 Members | 2,061 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,396 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 1603
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.