473,626 Members | 3,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1620
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
2134
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 <typename T> class BasicArray {
3
1325
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 allowing the derived class(es) directly access it? Should destructor always be virtual? Thanks for your comments!
1
297
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
1883
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 physical memory located on a piece of custom hardware - this memory is only accessible using machine specific i/o so I want to hide all this in a class. I'm imagining
13
16718
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
3874
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 http://home.pacific.net.sg/~jacksony ? (the drop down bar could not work at www.apchosting.net but can drop at home.pacific.net.sg. I suspect it is a server problem but was told it is not possible, therefore assuming it is a client script problem? the script works last time...
2
1885
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 method? I'm not sure if this makes sense, but can/should you put more than one class in a file (myclasses.cs)? Any help would be appreciated... Thanks, sck10
4
1626
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 basics and I know how to code OO. What I'm having problems with is understanding how to design/architect projects using OO. Can anyone reccomend any good online tutorials / online learning / video tutorials which deal with these subjects...
30
2450
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 carrying the original pointer. In other words, for the simplest usage code: * no overhead (just carrying a pointer or two), and * no possibility of exceptions (for that case).
7
2487
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 in IE 6 browser but not in Mozilla 4.0 some components are disappears. This is the whole code i used for designing this page and i also given css files coding.(except images) i don't know how to upload my files in this site(forum). So i am...
0
8707
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8366
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7199
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6125
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5575
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4202
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2628
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1512
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.