Annotation of mstools/mfc/samples/tutorial/person.h, revision 1.1

1.1     ! root        1: // person.h : Defines the class interfaces for CPerson, CPersonList.
        !             2: //
        !             3: // This is a part of the Microsoft Foundation Classes C++ library.
        !             4: // Copyright (C) 1992 Microsoft Corporation
        !             5: // All rights reserved.
        !             6: //
        !             7: // This source code is only intended as a supplement to the
        !             8: // Microsoft Foundation Classes Reference and Microsoft
        !             9: // QuickHelp documentation provided with the library.
        !            10: // See these sources for detailed information regarding the
        !            11: // Microsoft Foundation Classes product.
        !            12: 
        !            13: #ifndef __PERSON_H__
        !            14: #define __PERSON_H__
        !            15: #ifdef _DOS
        !            16:        #include <afx.h>
        !            17: #else
        !            18: #ifdef _NTWIN
        !            19:        #include <afx.h>
        !            20: #else
        !            21:        #include <afxwin.h>
        !            22: #endif
        !            23: #endif
        !            24: #include <afxcoll.h>
        !            25: 
        !            26: 
        !            27: /////////////////////////////////////////////////////////////////////////////
        !            28: // class CPerson:
        !            29: // Represents one person in the phone database.  This class is derived from
        !            30: // CObject (mostly to get access to the serialization protocol).
        !            31: 
        !            32: class CPerson : public CObject
        !            33: {
        !            34:        DECLARE_SERIAL( CPerson );
        !            35: 
        !            36: public:
        !            37: //Construction
        !            38:        // For serializable classes, declare a constructor with no arguments.
        !            39:        CPerson()
        !            40:                { m_modTime = CTime::GetCurrentTime(); }
        !            41:                
        !            42:        CPerson( const CPerson& a );
        !            43: 
        !            44:        // For our convenience, also declare a constructor with arguments.
        !            45:        CPerson( const char* pszLastName,
        !            46:                const char* pszFirstName,
        !            47:                const char* pszPhoneNum );
        !            48: 
        !            49: //Attributes
        !            50:        // Member functions to modify the protected member variables.
        !            51:        void SetLastName( const char* pszName )
        !            52:                {   ASSERT_VALID( this );
        !            53:                        ASSERT( pszName != NULL);
        !            54:                        m_LastName = pszName;
        !            55:                        m_modTime = CTime::GetCurrentTime(); }
        !            56:                        
        !            57:        const CString& GetLastName() const
        !            58:                {   ASSERT_VALID( this );
        !            59:                        return m_LastName; }
        !            60: 
        !            61:        void SetFirstName( const char* pszName )
        !            62:                {   ASSERT_VALID( this );
        !            63:                        ASSERT( pszName != NULL );
        !            64:                        m_FirstName = pszName;
        !            65:                        m_modTime = CTime::GetCurrentTime(); }
        !            66:                        
        !            67:        const CString& GetFirstName() const
        !            68:                {   ASSERT_VALID( this );
        !            69:                        return m_FirstName; }
        !            70: 
        !            71:        void SetPhoneNumber( const char* pszNumber )
        !            72:                {   ASSERT_VALID( this );
        !            73:                        ASSERT( pszNumber != NULL );
        !            74:                        m_PhoneNumber = pszNumber;
        !            75:                        m_modTime = CTime::GetCurrentTime(); }
        !            76:                        
        !            77:        const CString& GetPhoneNumber() const
        !            78:                {   ASSERT_VALID( this );
        !            79:                        return m_PhoneNumber; }
        !            80: 
        !            81:        const CTime GetModTime() const
        !            82:                {   ASSERT_VALID( this );
        !            83:                        return m_modTime; }
        !            84: 
        !            85: //Operations
        !            86:        CPerson& operator=( const CPerson& b );
        !            87: 
        !            88: //Implementation
        !            89: protected:
        !            90:        // Member variables that hold data for person
        !            91:        CString        m_LastName;
        !            92:        CString        m_FirstName;
        !            93:        CString        m_PhoneNumber;
        !            94:        CTime          m_modTime;
        !            95: 
        !            96: public:
        !            97:        // Override the Serialize function
        !            98:        virtual void Serialize( CArchive& archive );
        !            99: 
        !           100: #ifdef _DEBUG
        !           101:        // Override Dump for debugging support
        !           102:        virtual void Dump( CDumpContext& dc ) const;
        !           103:        virtual void AssertValid() const;
        !           104: #endif
        !           105: };
        !           106: 
        !           107: /////////////////////////////////////////////////////////////////////////////
        !           108: // class CPersonList:
        !           109: // This represents a list of all persons in a phone database.  This class is
        !           110: // derived from CObList, a list of pointers to CObject-type objects.
        !           111: 
        !           112: class CPersonList : public CObList
        !           113: {
        !           114:        DECLARE_SERIAL( CPersonList )
        !           115:        
        !           116: public:
        !           117: //Construction
        !           118: 
        !           119:        CPersonList()
        !           120:                { m_bIsDirty = FALSE; }
        !           121: 
        !           122:        // Add new functions
        !           123:        CPersonList* FindPerson( const char * szTarget );
        !           124:        
        !           125:        // SetDirty/GetDirty
        !           126:        // Mark the person list as "dirty" (meaning "modified").  This flag can be
        !           127:        // checked later to see if the database needs to be saved.
        !           128:        //
        !           129:        void SetDirty( BOOL bDirty )
        !           130:                {   ASSERT_VALID( this );
        !           131:                        m_bIsDirty = bDirty; }
        !           132:        
        !           133:        BOOL GetDirty()
        !           134:                {   ASSERT_VALID( this );
        !           135:                        return m_bIsDirty; }
        !           136: 
        !           137:        // Delete All will delete the Person objects as well as the pointers.
        !           138:        void DeleteAll();
        !           139:        
        !           140: protected:
        !           141:        BOOL  m_bIsDirty;
        !           142: };
        !           143: 
        !           144: /////////////////////////////////////////////////////////////////////////////
        !           145: 
        !           146: #endif // __PERSON_H__
        !           147: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.