473,396 Members | 2,059 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.

Class giving back information

My problem is that I have a Class (a socket-class to be precise) that
generates data (eg. it fetches a HTML document over an HTTP
connection).
This data is to be elaborated later by another class.
How do I communicate the data from one object to another?
What is a better style:
1) Add a member variable to the socket which points to the data
container in the elaborator.
2) Call the elaborator (create and execute) from within the socket
class.
3) Make an external (in the function that calls the socket) data
container which is shared with both objects.
4) Anything you may think of ...

Jul 22 '05 #1
2 1027
Snyke wrote:

My problem is that I have a Class (a socket-class to be precise) that
generates data (eg. it fetches a HTML document over an HTTP
connection).
This data is to be elaborated later by another class.
How do I communicate the data from one object to another?
What is a better style:
1) Add a member variable to the socket which points to the data
container in the elaborator.
2) Call the elaborator (create and execute) from within the socket
class.
3) Make an external (in the function that calls the socket) data
container which is shared with both objects.
4) Anything you may think of ...


I opt for 4)

class Data
{
....
};

class Fetcher
{
...
bool Fetch( Data& FetchedData );
};

class Elaborator
{
...
void Elaborate( const Data& TheData );
};

int main()
{
Data TheData;
Fetcher TheFetcher;
Elaborator TheElaborator;

if( TheFetcher.Fetch( TheData ) )
TheElaborator.Elaborate( TheData );
else
cout << "An error has occoured during fetching the data\n";
}

--
Karl Heinz Buchegger
kb******@gascad.at
Jul 22 '05 #2
Data {
....
};

Socket {
........

Data getData();
}

Elaborate {
elaborateData(Data &data) {
if(!data.isNull()) {
// Treatment
}
}
.....
}

Anil Mamede
Snyke wrote:
My problem is that I have a Class (a socket-class to be precise) that
generates data (eg. it fetches a HTML document over an HTTP
connection).
This data is to be elaborated later by another class.
How do I communicate the data from one object to another?
What is a better style:
1) Add a member variable to the socket which points to the data
container in the elaborator.
2) Call the elaborator (create and execute) from within the socket
class.
3) Make an external (in the function that calls the socket) data
container which is shared with both objects.
4) Anything you may think of ...

Jul 22 '05 #3

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

Similar topics

50
by: Dan Perl | last post by:
There is something with initializing mutable class attributes that I am struggling with. I'll use an example to explain: class Father: attr1=None # this is OK attr2= # this is wrong...
1
by: Sean W. Quinn | last post by:
Hey folks, I have a question regarding file handling, and the preservation of class structure. I have a class (and I will post snippets of code later in the post) with both primitive data...
21
by: Jon Slaughter | last post by:
I have a class that is basicaly duplicated throughout several files with only members names changing according to the class name yet with virtually the exact same coding going on. e.g. class...
4
by: Typpo | last post by:
Hi, This question is somewhat basic. Is it possible to call a method in frmMain, using another class? Here's a snippet: partial class frmMain : Form { private void MessageThis(String text)...
9
by: thomson | last post by:
Hi all, Would you please explain me where will be the heap stored if it is declared inside the Class, As class is a reference type, so it gets stored on the heap, but struct is a value...
4
by: Joseph Geretz | last post by:
We use a Soap Header to pass a token class (m_Token) back and forth with authenticated session information. Given the following implementation for our Logout method, I vastly prefer to simply code...
3
by: Peter Oliphant | last post by:
It's not necessary, but it would be nice if there was a way I could easily create something like a 'web browser form' or a 'display web page form' as forms in my application (in a Panel would be...
1
by: jc | last post by:
RE: Why use a CollectionBase class here vs dataset or dataview? I'm looking at some vb.net 2005 code that was generated from a homegrown Codesmith Template that generate all of the retreival and...
33
by: Peng Yu | last post by:
Hi, __PRETTY_FUNCTION__ is a macro that gives function name, etc. I'm wondering if there is a macro to get the class name inside a member function. Thanks, Peng
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.