|
Thanks a lot to both of you for your advice. I will definitely take them under consideration when I move to high-rate transfers.
jpyp
|
|
|
|
|
Is it possible somehow to derive several classes from a singleton class? Or would it be better to just create a global singleton and create an instance whenever required?
I want to create some sort of logger class, which would write the errors/logs to a file and optionaly display a dialog. The obvious place for such a class would be the top of the heirarchy. But in my case some classes are derived from multiple others.
|
|
|
|
|
I don't see exactly what you are trying to do... What is the exact 'scheme' that you are trying to get ?
Could you explain a little bit more in detail ? (Maybe with some code example).
|
|
|
|
|
It goes like this. I have a rather large collection of classes, all intertwined with each other. There is only one class at the bottom of the hierarchy, but it branches out towards the top. Now an error could happen anywhere within this structure. When one does happen I need to be able to log it to a file, and/or display it to the user. Currently All my error codes are HRESULTs and I have created a simple macro to pop-up a dialog box thinking I would just change the macro when it comes to dealing with the errors in the proper way.
I don't want to have to open a file, seek and write everytime I need to write to it; so I'm thinking of creating a static class which would map the file to memory and keep it open for the duration of the process. Obviously it would need to be a singleton due to the number of classes which need to access the file. But I can't think where to place such a class in this hierarchy.
|
|
|
|
|
I still don't understand fully your problem. Why don't you have a logger class which is completely 'external' to your class hierarchy. This class is simply a singleton and you can initialize it once at the startup of your program. Then, each time you need it, you get the singleton instance and call a function that log text.
BTW, as we speak about singleton, I suppose that you are refering to the singleton design pattern right (and not just a simple global instance) ? So, in that case, you really don't need to 'place' your class somewhere.
|
|
|
|
|
Cedric Moonen wrote: I suppose that you are refering to the singleton design pattern right
Yes I am.
I was just thinking the same as what you suggested. I was worrying about having an open handle to a file, but I wasn't thinking that with a singleton the c'tor and d'tor are only called once. I could even implement reference counting.
Why ain't I thinking straight tonight...
|
|
|
|
|
WalderMort wrote: I was worrying about having an open handle to a fil
Well, you don't need. If you provide the filename of your file at the startup of your program, you can still keep it as a data member of your class and then reopen the file (in append mode) to log the new message.
(If you are interested, I can post a very simple singleton logger class that I did).
|
|
|
|
|
Cedric Moonen wrote: (If you are interested, I can post a very simple singleton logger class that I did).
Thanks for the offer, but I would prefer to have a dab at it myself.
Cedric Moonen wrote: reopen the file (in append mode)
I was thinking more along the lines of mapping the file to memory. Due to the nature of the program, I would have to divide the file into sections ( OS version, DLL versions, Errors, Bank account numbers.. ) anyway you get the meaning.
|
|
|
|
|
I have a program that takes automatically reads points from a device connected through USB. The program will take these points and store it in a comma seperated Excel file. What I want to be able to do is graph these points using Excel from C++. I'm guessing the best way to do this is to make a macro that graphs the points and then making the C++ program call the macro. But I have no idea how to do this and I'm actually completely new to it. I do know how to make the macro in Excel. But how do I call the macro from C++??? I"m using Win32 API. Does anyone have experience with this?
Thank You!
-- modified at 16:16 Tuesday 6th February, 2007
-- modified at 16:18 Tuesday 6th February, 2007
------------------------
Impossible is Nothing
|
|
|
|
|
I want to insert a large binary data in to database( SQL server 2000 ) using VC6.
First I tried with RFX_Binary, with CByteArray but in that case I was able to insert only 8000 byte of data. After that data trunctaion error occures.
Then I tried with CLongBinary but in MFC RBX_LongBinary don't support. As I got assert at
<br />
void AFXAPI RFX_LongBinary(CFieldExchange* pFX, LPCTSTR szName,<br />
CLongBinary& value)<br />
{<br />
:<br />
:<br />
:<br />
case CFieldExchange::BindParam:<br />
ASSERT(FALSE);<br />
:<br />
:<br />
:<br />
}<br />
Please suggest any method to try.
Regards
Anil
|
|
|
|
|
|
in SQL table its image type.
When I write SQL statement in SQL manager I am able to insert more than 8K.
Its in the MFC side giving data truncation exception.
Regards
Anil
Regards
Anil
|
|
|
|
|
What type of field is the CByteArray object mapped to in the SQL table? The char, varchar, binary and varbinary types are limited to 8,000 bytes.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
in SQL table its image type.
When I write SQL statement in SQL manager I am able to insert more than 8K.
Its in the MFC side giving data truncation exception.
Regards
Anil
|
|
|
|
|
What does your RFX_Binary() statement look like?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
RFX_Binary(pFX, _T("[@File]"), mFileParam, 800000);
here I have given size more that 8000
Regards
Anil
|
|
|
|
|
i have to open an xml file in txt format. ie we would normally do right click open file with note pad no. similarly i have to open a file named system.xml as system.txt programmatically and then i have to read the file. does anyone having code for this. this should be done in c programming. help me. thanx in advance
Arise Awake Stop Not Till ur Goal is Reached.
|
|
|
|
|
|
i tried fopen. but this normally used to open a file in a specified format na. i need to open an already created xml file as text file in my program and then i have to read the contents. i think fopen cant be used.
|
|
|
|
|
A xml file *is* a text file. There are no problems what so ever to use fopen in order to open a xml file.
(Furthermore, there are no problems opening a binary file either. Just give the correct opening flags, i.e. "rt" for reading a text file, "rb" for reading a binary file).
But there are newer ways of file handling besides using the old C functions. Consider using them.
Alcohol. The cause of, and the solution to, all of life's problems - Homer Simpson
|
|
|
|
|
There is no such thing as "opening a file in a specific format".
If there was, then every file format would have a corresponding C-function for opening it.
It's up to you to know the format of the file you're opening. The only thing you can choose from is whether carriage return and line feed combinations should be translated to a single line feed or not. That's the difference between calling fopen with or without the "t" switch in the mode string.
When you've opened the file with fopen you can use fread for reading the contents of the file and fclose for closing it.
Consider using file operations from MFC framework or STL library instead.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
|
|
|
|
|
deeps_cute wrote: i tried fopen.
Then what was problem ?
deeps_cute wrote: i think fopen cant be used.
It can be.
As mentioned earlier, its a text file. Follow code, you would write for a text file.
deeps_cute wrote: but this normally used to open a file in a specified format na
I think you are mistaking file formats with opening mode. In case of file format like .doc you can use fopen , but you cant read its content to your like because of its format. But thats not issue with .xml file.
|
|
|
|
|
Hello , I am new to VC++ 6.0
I am now developing a MFC dialog based project which will display the signal information in real time and signal strength.
[IMG]http://i176.photobucket.com/albums/w196/well_aisec/image-1.jpg[/IMG]
I need to have 1 analog meter which will constantly update the signal strength value as well as an oscilloscope which will graph the received signal in real time. What I will do to set a Timer which will trigger every 250ms for update and display in Analog meter. At the same time I need to perform
real time graphing for the signal. Meaning the two task is perform asynchronously.
Now here's come the problem.
As the timer is triggered in fast speed, my program seems very laggy to perform both operation in parallel.
May I know what's the problem and solutions?The timer consume a lot of memory space and processing speed? How to improve the program so that it can progress smoothly.
Thanks
|
|
|
|
|
What hardware do you use to collect the signal strength values?
Probably you should have a worker thread waiting on a waitable timer or multimedia timer event. When the timer expires a signal strength value sample is created and assigned a time stamp and put in a queue to be read by the main thread which should be responsible for the presentation.
In cases like this it's usually the data gathering which is time critical. It doesn't matter if the GUI is running 50ms late, the user won't notice anyway but the data would be correct (or as accurate as possible).
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
|
|
|
|
|
The signal strength values comes from a receiver, very much like a radio which will be connected to our serial port.
I am not sure the method you were referring( maybe you can further elaborate in a simple way which i can easily understand?). What I did was my program will be collect signal strength values at the predefined frequency. As the signal strength value of a fixed frequency keep on changes, I created a timer with 250ms time interval to read and update the display. This timer will trigger an event to collect signal strength and update the meter
-- modified at 11:05 Tuesday 6th February, 2007
|
|
|
|