|
I am very new to VC++, so I thank you for ur direction and assistance!
Happy New Year to all!
|
|
|
|
|
I'm sure the answer is obvious but I can't seem to work it out.
I have a created a class (called Cemu) which is tagged as serializable via MFC's macros. Now in Cemu there consist a couple of CString's which I want to serialize. To complicate matters I have a list of Cemu entries stored in CemuList. What I have done when I want to dump the list to the file is loop through CemuList and call the serialize() method I created in Cemu which in turn writes out the CStrings I want to a file. That process seems to work just fine by examining the file afterwards. What I'm have trouble with is de-serializing. My initial stab at it is below but that doesn't work.
while (file.GetPosition() < file.GetLength()) {
client = new Cemu;
client->Serialize(archive);
CemulList.AddTail(*client);
}
The file containing the data has 2 Cemu serialised entries and what I'm finding is that only one gets read in. My interpretation was that the act of serializing the Cemu would move the file pointer along correctly, ie a total of 2 times but I'm missing something. Can point me in the right direction?
Cheers!
|
|
|
|
|
jbem wrote: Can point me in the right direction?
See this[^] article.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Nice work Ravi - Ive just pointed your work out to a Larry Mills, 2 posts above this one
'g'
-- modified at 21:35 Friday 30th December, 2005
|
|
|
|
|
Thanks Ravi. I initially saw these primers and had a bit of a read through all 3 of them so thanks for putting the effort in to write them up.
The thing I have a problem and which I was trying to avoid was having to store the number of items in the actual file. It seemed rather logical to me that if you know the way you stored data for a class you should be able to serialize chunks which would automatically walk the file in the right increments via the archive buffer till EOF on deserialization. I guess not.
So the thing I get out of all this is that if you have a list of objects of a type that you want to serialize then there is no other way than to store the number of objects as the first item if you ever want to recreate that list of objects ever again. I guess CArchive has no concept, that is exposed to the user, of file position based on what it has serialized just more like a buffer position internally.
|
|
|
|
|
jbem wrote: avoid was having to store the number of items in the actual file
This is a VBT (very bad thing ) because it enforces the dependency that the collection be the last (or only) data stored in the file.
jbem wrote: CArchive has no concept, that is exposed to the user, of file position based on what it has serialized just more like a buffer position internally
Correct. And nor should it, since it's really just a stream (that may be part of another stream). That's where the power of object oriented serialization comes in. If you later choose to embed your collection in another object, you don't need to change your collection serialization code as it's location agnostic.
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
One of the ways that I've gotten around this is by outputting the number of elements in the list before outputting the list. Then reading that number at load time to see how many elements are getting ready to get read:
int numElements;
if( ar.IsStoring() )
{
numElements = _yourList.GetCount();
ar << numElements;
POSITION pos = _yourList.GetHeadPosition();
while( pos )
{
YourType currElement = _yourList.GetNext( pos );
currElement.Serialize( ar );
}
}
else
{
_yourList.RemoveAll();
ar >> numElements;
for( int i = 0; i < numElements; ++i )
{
YourType newElement;
newElement.Serialize( ar );
_yourList.AddTail( newElement );
}
}
That's untested code, but you should get the idea.
-- modified at 15:34 Friday 30th December, 2005
|
|
|
|
|
Thanks ToxickZero. Same solution as Ravi offered also and works fine as I just implemented it. Pity you need to keep track of the number of elements when serializing. Wish it could be done in a more dynamic fashion but it seems as it is not to be.
|
|
|
|
|
Hi jbem
I'm not sure that your conclusion that you have to keep track of the number of items in the list is correct.
The list classes contain Serialize functions, and if you use these they keep track for you.
A while back I was builiding a simulator that contained a recursive structure of models and submodels, similar to your Cemu class. My class was CModel, of type CModelObject. It contained a list, m_ModelList, pointing to the submodels (also of type CModel).
m_ModelList was of type CModelList, declared as follows:
typedef CTypedPtrList<CObList, CModelObject*> CModelList;
And the CModel Serialize function was:
void CModel::Serialize(CArchive & ar)<br />
{<br />
CModelObject::Serialize(ar);<br />
<br />
m_ModelList.Serialize(ar);<br />
<br />
if (ar.IsStoring())<br />
{<br />
ar << m_Name<br />
<< m_Notes<br />
<< m_AtomOrMacroNotes;<br />
}<br />
else<br />
{<br />
ar >> m_Name<br />
>> m_Notes<br />
>> m_AtomOrMacroNotes;<br />
}<br />
}
The function saves the properties of the particular CModel object, m_Name, m_Notes, etc., and those defined in the base clase, CModelObject - and it saves the submodels by calling m_ModelList.Serialise(ar). When de-serializing, this call reinstates the list and all its associated objects.
I've stripped a lot of detail out of the example, but amongst the model properties there were also pointers to other models - so there were very many mutually recursive references, and I remember being concerned about how to tie all this back together on de-serialization. I was pleasantly suprised to find that the serialization mechanism looked after all of this for me automatically. I think it is an elegant system and a credit to its designers. It seems that all the user has to do is make sure that things are serialized and de-serialized in the same order.
Best Regards
Cliff
-- modified at 6:58 Sunday 1st January, 2006
|
|
|
|
|
It just occurred to me that I may have misread your question. I thought you meant that your Cemulist was a member of Cemu, comprising a recursive structure. Apologies if I have caused any confusion.
I would still suggest the same solution though. You could try calling the list's Serialize function from within the Serialize function of whatever object contains the Cemulist, in the same way as I did with m_ModelList.
The serialize functions of the list classes invoke the serialize functions of all the things the list points to, so they save the whole structure. I imagine they also write out the number of items, but this is unseen by the user.
|
|
|
|
|
I have developed one MDI application.
I created one child window or it comes as default.
but it size is smaller than the mainframe window
how to fit it with parent window
|| ART OF LIVING ||
|
|
|
|
|
You need to rethink your quesiton. A child windows will (almost) always be smaller than the mainframe window size, as it needs to fit within the client area of the mainframe window.
There is a flag you can set that will make the new window/view/child window maximized on creation (fill client area), but I forget what it is. You'll just need to look it up like the rest of us.
INTP
Every thing is relative...
|
|
|
|
|
hi ;
i am doing a proj(vc6) which include file transfer in lan the code i used is
......send
byte* data = new byte[4096];
file.Open("filename",CFile::modeRead|CFile::typeBinary);
do
{
dwRead = file.Read(data,4096);
sock.Send(data,dwRead);
}
while (dwRead>0);
delete data;
file.Close();
.........rec
byte* data = new byte[4096];
file.Open("filename",CFile::modeWrite|CFile::typeBinary);
do
{
dwRead = sock.Recive(data,4096);
file.Write(data,dwRead);
}
while (dwRead>0);
delete data;
file.Close();
..............
the prblm i am facing is that i got transer sound and some other stuffs,which is clear and perfectly working i am able to do that but while in file transer it take lot of time ie abt 30 sec for 500kb of data i got 100 mbps network so i think it should take around few sec ie 1-2 sec anyone got a solution for this do reply
Happy New Programming Year
joby
jobythomas24@gmail.com
|
|
|
|
|
Try asyncronouse sockets (not straight forward), synchronous data transfers are always slow.
-Prakash
|
|
|
|
|
How do i check the minimum PC configuration that is required to run an application that i have written in VC++.
By PC configuration i mean the processor speed, memory, hard disc space etc.
My application captures video from usb port and tv tuner and process about 30 frames/sec.
I am sorry if this is not the right forum to ask.
Regards,
Nripun
|
|
|
|
|
|
|
i am not looking for a VC++ program which returns the PC configuration.
for that matter i am not looking for any program.
I have written an application. When i deliver this application i have to mention in the catlogue the minimun PC requirement. Can u please tell me how to check if it will run in a P3 and not in a P2 processor
-- modified at 8:43 Friday 30th December, 2005
|
|
|
|
|
What I understood know is that ur application is hardware dependent.If I m right then it is not a simple application but a device driver or system programming sort of thing u have done.
never say die
-- modified at 8:59 Friday 30th December, 2005
|
|
|
|
|
i shudnt have mentioned the usb and tuners in my post. that created the confusion. Let me try and make it a lil more simple.
I wrote an application.
Will in work fine on a P1/P2/P3 processors?
How can i find tat out?
Do i have to keep trying on older pcs until i find one in which it doesnt run??
I hope there is a better way
-- modified at 11:24 Friday 30th December, 2005
|
|
|
|
|
If it is a normal application then Hardware problem is not that significant unless ur appilcation is not meant for specific OS say WinXP (in this case WinXP specification is required).Still u can check ur application in another hardware configuration for ur satisfaction
never say die
-- modified at 9:22 Friday 30th December, 2005
|
|
|
|
|
I have build an help file to document my program.
I have done an item on my menu to execute it.
Im my Computer it's work well but when I execute my exe file in an other pc it search an HLP file (c:\miki\suivib.HLP, suivib is the name of my program).
What to do so that the help file became part of my program, any where i can execute it.
I learn my self
|
|
|
|
|
To me has fallen the task of documenting an in-house database created in OLE 2.0. This DB is accessed only through an API of which there is no source code. Through attrition and evidently poor documentation, the DB layout is basically lost. It is also quite complex with subsequent programmers, who did not understand it, jury rigging it to add functionality to it. Viewing it in Docfile Viewer does show the various "tables" within the DB, and the Uni-Code data is plain to see. Trying to traverse the DB manually and figure out how the system of pointers is working is making no sense to me. Of course without the layout, it's hard to tell what IS a pointer within the DB. I have worked with DB's of a similar nature and complexity before where we did have the layout and was successful with those. Creating a simple record in this DB using the existing software and then trying to see the before and after in simple additions to the data are not working for me.
My question is: Is there anyone that could give me some pointers on where to go with this? Are there good tools to use? I do have the C++ debugger for the executable only (no source code, remember) and the Doc File Viewer.
Sheljo
|
|
|
|
|
hi...
I am using Window CE emulator as a CPU choice to debug my eVC++ program.Can i able to open my PC's com port thrugh this emulator option.I am running this emulator in Window XP environment.
thanx in advance..
birajendu
CyberG India
Delhi
India
|
|
|
|
|
It started because I wanted a graduated caption bar. I then wanted different buttons - Close, Minimize and Help. I can draw these ok using variations on the famous Paul DiLascia caption project. The Help button occupies the place of the conventional Minimize, and the Minimize occupies the place of the conventional Maximize. How does Windows handle the tooltips, it seems to be by some arcane process. I want to know how to display the correct tooltips and to respond correcly to button presses.
Dave Regan (new to Windows - exVMS man)
-- modified at 11:55 Friday 30th December, 2005
I know about CToolTipCtrl and have used it elsewhere. The difficulty is in knowing where and what to override in CFrameWnd to intercept the system framework tool tips. Spy reveals the only messages are WM_NCMOUSEMOVE, WM_SETCURSOR, and WM_NCHITTEST. I'm assuming that after enough WM_NCHITTESTs are received with the same coords the 'hidden' system functions respond.
|
|
|
|