CMemorySegment.h 3.63 KB
//=========================================================
//
//  Class Name:	CMemorySegment
//  Author:  
//  Company:  VAutomation An Arc Cores Company
//  Date created:  3/20/2002 at 10:22
//
//
//==========================================================
//
//  No notes.
//
//
//
//==========================================================

#ifndef __CMEMORYSEGMENT__
#define __CMEMORYSEGMENT__

//=========================================================
// Member Varible Includes
//=========================================================



//=========================================================
//             HEADER INCLUDE FILE SECTION
//=========================================================
#include "DataTypes.h"
#include "SystemAccess.h"
#include "MessageIO.h"


//=========================================================
//                       TYPES
//=========================================================

//=========================================================
//                       Constants
//=========================================================
const UnSignedLong DefaultMaxCacheSizeInBytes = 256;

//=========================================================
//
// Class Comments:
// 
// 	This class is designed to keep track of the memory when attempting
// 	to get aligned memory.
// 	
// 
// Public function comments:
// 
// 	Create:
// 		This function will allocate a segment of memory on a byte boundary and set the init value.
// 
// 	Address:
// 		Returns the address of the first working byte of the aligned segment
// 
// 
// Private function comments:
// 
// 
// Protected function comments:
// 
// 
//=========================================================

class CMemorySegment
{

  public:

	// Member functions
	bool Create
		( const UnSignedLong working_data_bytes, // Number of bytes for data access
		  const UnSignedLong alignment_boundary, // The byte boundary required for this segment
		  const unsigned char init_value = 0 // The init value of the memory
		); // Return Value: Success of this operation.

	bool PrintWorkingDataBytes( CMessageIO& g_message_interface );

	volatile AddressType GetWorkingAddress
		(		) const; // Return Value: Pointer to the address of the first working byte in the segment

	// Member functions default overrides
	CMemorySegment( ); // Default constructor
	virtual ~CMemorySegment( ); // Destructor
	CMemorySegment( const CMemorySegment &cmemorysegment_item ); // Copy constructor

	// Operator Members
	CMemorySegment& operator = ( const CMemorySegment &cmemorysegment_item );
	bool operator == ( const CMemorySegment &cmemorysegment_item ) const;

	// GetCopy Member Functions
	UnSignedLong GetCopyWorkingByteSize( void ) const;
	UnSignedLong GetCopyTrueByteSize( void ) const;

	// Set Member Functions
	bool SetWorkingAddressForAccessOnly( volatile AddressType access_only_address );
	

  public:

	// Member varibles


  private:

	// Member functions


  private:

	// Member varibles
	volatile unsigned char *m_true_heap_start_address; //Keeps the start address in the heap segment
	volatile unsigned char *m_working_start_address; //Keeps the first address of the working memory 
	UnSignedLong m_working_byte_size; //The number of bytes in the working area of the segment
	UnSignedLong m_true_byte_size; //The number of bytes allocated in the heap
	UnSignedLong m_alignment_boundary; //The bound the working memory is aligned to


  protected:

	// Member functions
	void CopyDataToThis( const CMemorySegment &cmemorysegment_item ); //Class copy internal data.

  protected:

	// Member varibles


  public:

	// Friend functions

};

#endif

//=========================================================