 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Victor Bazarov Guest
|
Posted: Sat Feb 28, 2004 11:57 pm Post subject: Re: How to design such class? |
|
|
"alex" <alex (AT) xxx (DOT) net> wrote...
| Quote: | How to design a class that will read raw data from a piece of hardware and
the raw data will be constructed as 12-bit images, each 658x342 pixels?
|
When designing a class, do not concern yourself with what it does, but
with who and how is going to use the class. The usage will define the
class' interface, whereas the needed functionality is just the innards
of one or two specific member functions.
Victor
|
|
| Back to top |
|
 |
Alf P. Steinbach Guest
|
Posted: Sun Feb 29, 2004 12:11 am Post subject: Re: How to design such class? |
|
|
* "Victor Bazarov" <v.Abazarov (AT) comAcast (DOT) net> schriebt:
| Quote: |
"alex" <alex (AT) xxx (DOT) net> wrote...
How to design a class that will read raw data from a piece of hardware and
the raw data will be constructed as 12-bit images, each 658x342 pixels?
When designing a class, do not concern yourself with what it does, but
with who and how is going to use the class. The usage will define the
class' interface, whereas the needed functionality is just the innards
of one or two specific member functions.
|
Amen.
Just to clarify: alex, your problem isn't best solved by "a class", so forget
about "a class".
|
|
| Back to top |
|
 |
Razvan Popovici Guest
|
Posted: Sun Feb 29, 2004 8:28 am Post subject: Re: How to design such class? |
|
|
What about:
class CImageClass
{
public:
readDataFromHardware(void*wiredparameter,int intparameter ......);
writeDataToFile(const char* filename, .....);
private:
char[maxData] crawData;
bool bisDataInitialised; // false= no data is readed in rawdata, true= data
is loaded in rawdata
};
According your needs you can allocate rawData dynamically, in constructor
and keep the pointer null while no data is readed, so you kick out the
isDataInitialised member.
Good luck,
Razvan Popovici
"Alf P. Steinbach" <alfps (AT) start (DOT) no> schrieb im Newsbeitrag
news:40412d25.70261937 (AT) news (DOT) individual.net...
| Quote: | * "Victor Bazarov" <v.Abazarov (AT) comAcast (DOT) net> schriebt:
"alex" <alex (AT) xxx (DOT) net> wrote...
How to design a class that will read raw data from a piece of hardware
and
the raw data will be constructed as 12-bit images, each 658x342
pixels?
When designing a class, do not concern yourself with what it does, but
with who and how is going to use the class. The usage will define the
class' interface, whereas the needed functionality is just the innards
of one or two specific member functions.
Amen.
Just to clarify: alex, your problem isn't best solved by "a class", so
forget
about "a class".
|
|
|
| Back to top |
|
 |
Victor Bazarov Guest
|
Posted: Sun Feb 29, 2004 2:45 pm Post subject: Re: How to design such class? |
|
|
"Razvan Popovici" <me (AT) razvan_nospam (DOT) de> wrote...
| Quote: | What about:
class CImageClass
{
public:
readDataFromHardware(void*wiredparameter,int intparameter ......);
writeDataToFile(const char* filename, .....);
private:
char[maxData] crawData;
|
That's not C++.
| Quote: | bool bisDataInitialised; // false= no data is readed in rawdata, true=
data
is loaded in rawdata
};
According your needs you can allocate rawData dynamically, in constructor
|
Without knowing how much to allocate?
| Quote: | and keep the pointer null while no data is readed, so you kick out the
isDataInitialised member.
Good luck,
Razvan Popovici
"Alf P. Steinbach" <alfps (AT) start (DOT) no> schrieb im Newsbeitrag
news:40412d25.70261937 (AT) news (DOT) individual.net...
* "Victor Bazarov" <v.Abazarov (AT) comAcast (DOT) net> schriebt:
"alex" <alex (AT) xxx (DOT) net> wrote...
How to design a class that will read raw data from a piece of
hardware
and
the raw data will be constructed as 12-bit images, each 658x342
pixels?
When designing a class, do not concern yourself with what it does, but
with who and how is going to use the class. The usage will define the
class' interface, whereas the needed functionality is just the innards
of one or two specific member functions.
Amen.
Just to clarify: alex, your problem isn't best solved by "a class", so
forget
about "a class".
|
|
|
| Back to top |
|
 |
Razvan Popovici Guest
|
Posted: Sun Feb 29, 2004 9:44 pm Post subject: Re: How to design such class? |
|
|
"Victor Bazarov" <v.Abazarov (AT) comAcast (DOT) net> schrieb im Newsbeitrag
news:QVm0c.439540$na.1052068 (AT) attbi_s04 (DOT) ..
| Quote: | "Razvan Popovici" <me (AT) razvan_nospam (DOT) de> wrote...
What about:
class CImageClass
{
public:
readDataFromHardware(void*wiredparameter,int intparameter ......);
writeDataToFile(const char* filename, .....);
private:
char[maxData] crawData;
That's not C++.
|
he needs to read data from a _hardware_ device. Just use an autogrow stl
array (C++ like) and you will see a real performance reduction. maxData, or
better MAXDATA, should be a define symbol or a constant.
| Quote: |
bool bisDataInitialised; // false= no data is readed in rawdata, true=
data
is loaded in rawdata
};
According your needs you can allocate rawData dynamically, in
constructor
Without knowing how much to allocate?
|
We know how much to allocate .. we get the parameters of the image/hardware,
etc. If not, we can leave the pointer null and allocate exactly when we are
reading data.
| Quote: |
and keep the pointer null while no data is readed, so you kick out the
isDataInitialised member.
Good luck,
Razvan Popovici
"Alf P. Steinbach" <alfps (AT) start (DOT) no> schrieb im Newsbeitrag
news:40412d25.70261937 (AT) news (DOT) individual.net...
* "Victor Bazarov" <v.Abazarov (AT) comAcast (DOT) net> schriebt:
"alex" <alex (AT) xxx (DOT) net> wrote...
How to design a class that will read raw data from a piece of
hardware
and
the raw data will be constructed as 12-bit images, each 658x342
pixels?
When designing a class, do not concern yourself with what it does,
but
with who and how is going to use the class. The usage will define
the
class' interface, whereas the needed functionality is just the
innards
of one or two specific member functions.
Amen.
Just to clarify: alex, your problem isn't best solved by "a class", so
forget
about "a class".
|
|
|
| Back to top |
|
 |
Victor Bazarov Guest
|
Posted: Sun Feb 29, 2004 9:57 pm Post subject: Re: How to design such class? |
|
|
"Razvan Popovici" <me (AT) razvan_nospam (DOT) de> wrote...
| Quote: |
"Victor Bazarov" <v.Abazarov (AT) comAcast (DOT) net> schrieb im Newsbeitrag
news:QVm0c.439540$na.1052068 (AT) attbi_s04 (DOT) ..
"Razvan Popovici" <me (AT) razvan_nospam (DOT) de> wrote...
What about:
class CImageClass
{
public:
readDataFromHardware(void*wiredparameter,int intparameter ......);
writeDataToFile(const char* filename, .....);
private:
char[maxData] crawData;
That's not C++.
he needs to read data from a _hardware_ device. Just use an autogrow stl
array (C++ like) and you will see a real performance reduction. maxData,
or
better MAXDATA, should be a define symbol or a constant.
|
No matter what 'maxData' evaluates to, the declaration
char[maxData] crawData;
is a simple _syntax_error_. As a first step to understanding others
try to interpret their statements without any hidden meaning.
Also five or six periods in a row is a syntax error as well. And any
function declaration should have the return value type.
V
|
|
| Back to top |
|
 |
Razvan Popovici Guest
|
Posted: Mon Mar 01, 2004 6:46 pm Post subject: Re: How to design such class? |
|
|
I was just trying to draft the class implementation, it's obvious that x
periods in a row will not compile, but will make the autor of the question
understand how the class needs to be developed.
About the variable declaration you are right, but again, my concerns were
about analisys not programming.
Razvan
"Victor Bazarov" <v.Abazarov (AT) comAcast (DOT) net> schrieb im Newsbeitrag
news:3ft0c.10610$PR3.225969 (AT) attbi_s03 (DOT) ..
| Quote: | "Razvan Popovici" <me (AT) razvan_nospam (DOT) de> wrote...
"Victor Bazarov" <v.Abazarov (AT) comAcast (DOT) net> schrieb im Newsbeitrag
news:QVm0c.439540$na.1052068 (AT) attbi_s04 (DOT) ..
"Razvan Popovici" <me (AT) razvan_nospam (DOT) de> wrote...
What about:
class CImageClass
{
public:
readDataFromHardware(void*wiredparameter,int intparameter ......);
writeDataToFile(const char* filename, .....);
private:
char[maxData] crawData;
That's not C++.
he needs to read data from a _hardware_ device. Just use an autogrow stl
array (C++ like) and you will see a real performance reduction. maxData,
or
better MAXDATA, should be a define symbol or a constant.
No matter what 'maxData' evaluates to, the declaration
char[maxData] crawData;
is a simple _syntax_error_. As a first step to understanding others
try to interpret their statements without any hidden meaning.
Also five or six periods in a row is a syntax error as well. And any
function declaration should have the return value type.
V
|
|
|
| Back to top |
|
 |
Victor Bazarov Guest
|
Posted: Tue Mar 02, 2004 3:40 am Post subject: Re: How to design such class? |
|
|
"Razvan Popovici" <me (AT) razvan_nospam (DOT) de> wrote...
| Quote: | I was just trying to draft the class implementation, it's obvious that x
periods in a row will not compile, but will make the autor of the question
understand how the class needs to be developed.
About the variable declaration you are right, but again, my concerns were
about analisys not programming.
|
Too bad that you decided to do that in a language newsgroup. Perhaps
next time you take it where a particular language rules do not apply.
Consider using comments instead of ...... and 'void' where return value
type is not important.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|