Solved

Regarding Serialization ...

Posted on 1998-12-13
2
320 Views
Last Modified: 2013-11-20
hello everybody
I am going through MFC tutorials (Scribble). There is one object declared
as follows :

CTypePtrList<CObList, CStroke *> m_strokeList;

The serialise function in CScribbleDoc is declared as follows :

      if (ar.IsStoring())
      {
            // TODO: add storing code here
      }
      else
      {
            // TODO: add loading code here
      }

      m_strokeList.Serialize( ar );

And the serialise function for "CStroke" has been defined and implemented.
What i am unable to understand is that how does the serialise function
of "CStroke" is being called when i save the document.
What i understand is that m_strokeList.Serialise() calls the serialise
function of the base class "CObject". Now how does the base class knows
that the object being serialised is list of pointes which are to be
serialised one by one so that serialise function of CStroke is called
for all pointers in the m_strokeList.
 
The "DECLARE_SERIAL" and "IMPLEMENT_SERIAL" macros are present in CStroke.

0
Comment
Question by:aarya
2 Comments
 
LVL 15

Accepted Solution

by:
Tommy Hui earned 10 total points
ID: 1326123
The CList is derived from CObject. Basically, every CObject-derived class has the ability to serialize itself. So in this case, when the CList container is asked to serialize itself, it knows to store information about itself into the document. It also knows that there are objects in the link and saves them into a stream.

There's a book called MFC Internals by Sheppard and Wingo. Take a look at it if you want to know more about the internals of MFC.
0
 

Author Comment

by:aarya
ID: 1326124
Well, what i dont understand is that CObject derived class in this case CObList does not override the functionality of serialize function so how can CObject have knowledge to take care of the fact that each member of the CObList is to be serialized.

If CObList had been overriding the serialize function then i can understand how they would have implemented but otherwise how can u take care.

Any nice to have response from u.
 Thui it seems that u r point rich man. I have plenty of questions to ask but no points left. Can u do me a favor to lend few points.
 Thanks in advance.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Best tools for Backup and restore of Wordpress site 6 55
haveThree challenge 22 114
zeroMAx challenge 20 88
wordappend challenge 8 157
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now