void COXChildFrameState::Serialize(CArchive& ar)
	{
	ASSERT_VALID(this);

	// Check the version 
	// (If version == -1, the version is unknown, this occurs when Serialize() is called directly)
	if (ar.IsLoading())
		{
		m_nSerializeSchemaVersionLoad = (int)ar.GetObjectSchema();
		if (m_nSerializeSchemaVersion < m_nSerializeSchemaVersionLoad)
			{
			TRACE1("COXChildFrameState::Serialize : Unexpected schema version : %i, throwing CArchiveException\n", 
				m_nSerializeSchemaVersionLoad);
			AfxThrowArchiveException(CArchiveException::badSchema);
			}
		}

	// Call base class implementation
	CObject::Serialize(ar);

	// Serialize all data
	if (ar.IsStoring())
		StoreProperties(ar);
	else
		LoadProperties(ar);

	ASSERT_VALID(this);
	}
void CSchemaObject::Serialize(CArchive& ar) 
{
   CObject::Serialize(ar);

   if (ar.IsLoading())
   {
      int nVersion = ar.GetObjectSchema();

      switch(nVersion)
      {
         case 0:
            // read in previous version of 
            // this object
            break;
         case 1:
            // read in current version of
            // this object
            break;
         default:
            // report unknown version of 
            // this object
            break;
      }
   }
   else
   {
     // Normal storing code goes here
   }
}
예제 #3
0
void CBigBrotherDoc::Serialize(CArchive& ar)
{
	ASSERT_VALID(this);

	CDocument::Serialize(ar);

	ar.MapObject(this);
	ar.SerializeClass(RUNTIME_CLASS(CBigBrotherDoc));

	if (ar.IsStoring())
	{
		// Store to archive
		ar << m_PingSize;
		ar << m_MaxThreads;
		ar << m_MaxLogTime;
		ar << m_bSaveOnShutdown;
		ar << m_AutoSave;
		ar << m_LogFile;
		ar << m_bStoreLastActivity;
		ar << m_RootBrother;
		m_Brotherhood.Serialize(ar);
	}
	else
	{
	UINT	schema = ar.GetObjectSchema();
#ifndef	NDEBUG
		{
		CString tmp;
			tmp.Format("Doc-OSchema: %u\n",schema);
			TRACE0(tmp);
		}
#endif
		CleanUp();
		m_ThisMap.RemoveAll();
		// Read from archive
		ar >> m_PingSize;
		ar >> m_MaxThreads;
		ar >> m_MaxLogTime;
		if(schema>=2){
			ar >> m_bSaveOnShutdown;
			ar >> m_AutoSave;
		}
		ar >> m_LogFile;
		if(schema>=3)
			ar >> m_bStoreLastActivity;
		ar >> m_RootBrother;
		m_Brotherhood.Serialize(ar);
		// Read from archive
		m_ThisMap.RemoveAll();
		// Log loading
	CString logLine;
		logLine.Format(IDS_LOG_LOADFILE,(LPCTSTR)GetTitle());
		logLine=CTime::GetCurrentTime().Format(IDS_LOG_DATEFORMAT)+" "+logLine;
		LogLine(logLine);
	}
예제 #4
0
// overloading save and load procedures
void CExponent::Serialize(CArchive& ar)
{
	UINT t=0;
	if (ar.IsStoring())
	{
		if (m_Method!=NULL) t=m_Method->GetType();
		ar << m_Name << m_Description << m_Grad << m_Type << m_scale << t << m_dMaxValue << m_dMinValue << m_iDirBest << m_id;
		if (m_Method!=NULL) m_Method->SerializeNew(ar);
	}
	else
	{
		int nVersion = ar.GetObjectSchema();

		switch(nVersion)
		{
		case 1:
			// read in previous version of 
			// this object
			ar >>  m_Name >> m_Description >> m_Grad >> m_Type >> m_scale >> t;
			break;
		case 2:
			ar >>  m_Name >> m_Description >> m_Grad >> m_Type >> m_scale >> t >> m_dMaxValue >> m_dMinValue >> m_iDirBest;
			break;
		case 3:
			// read in current version of
			// this object
			ar >>  m_Name >> m_Description >> m_Grad >> m_Type >> m_scale >> t >> m_dMaxValue >> m_dMinValue >> m_iDirBest >> m_id;
			break;
		default:
         // report unknown version of 
         // this object
			TRACE("unknown version!!!");
			break;
		}
   		if (t)
		{
			CMethodFactory f;
			m_Method=f.CreateObject(t);
			if (nVersion<3) m_Method->Serialize(ar);
			else m_Method->SerializeNew(ar);
			m_Method->m_pE=this;
		}
	};
}