model_server/gala/src/controlObjects.cxx
//---------------------------------------------------------------------------------------------------------
// loads spesified image from the resource file. If this image is already in use it will return
// it's address and increment it's reference cound to perform LRU strategy. If this image is not
// in the image buffer and there are free places to hold this image the function will load the 
// image into any empty place. If there are no empty places it will first remove the image 
// with smallest reference count. If there is no such image in the resource file this function
// will do nothing and return NULL;
//--------------------------------------------------------------------------------------------------------
loads spesified image from the resource file. If this image is already in use it will return
it's address and increment it's reference cound to perform LRU strategy. If this image is not
in the image buffer and there are free places to hold this image the function will load the
image into any empty place. If there are no empty places it will first remove the image
with smallest reference count. If there is no such image in the resource file this function
will do nothing and return NULL.
loads spesified image from the resource file . If this image is already in use it will return it ' s address and increment it ' s reference cound to perform LRU strategy . If this image is not in the image buffer and there are free places to hold this image the function will load the image into any empty place . If there are no empty places it will first remove the image with smallest reference count . If there is no such image in the resource file this function will do nothing and return NULL .
vimage* imageBuffer::GetImageFromResource(gString* imageName) {
		int index;
		index = findName(imageName);
		if(index>=0) {
			if(m_Buffer[index]->m_refCount<32000)
				m_Buffer[index]->m_refCount++;
			return m_Buffer[index]->m_Image;
		}
		vresource imageResource;
		if(getResource((char *)(*imageName),&imageResource)==0) return NULL;
		index = findEmptyCell(); 
		if(index<0) { 
			index= findLRUCell();
			delete m_Buffer[index]->m_Image;
			delete m_Buffer[index]->m_Name;
			delete m_Buffer[index];
			m_Buffer[index]=NULL;
		}
		m_Buffer[index]=new BufferEntry;
		m_Buffer[index]->m_Image = new vimage;
		m_Buffer[index]->m_Name  = new gString;
		m_Buffer[index]->m_refCount=1;
		m_Buffer[index]->m_Image->Load(imageResource);
		(*m_Buffer[index]->m_Name) = *imageName;
		return 	m_Buffer[index]->m_Image;
	}
vimage * imageBuffer :: GetImageFromResource ( gString * imageName ) { int index ; index = findName ( imageName ) ; if ( index >= 0 ) { if ( m_Buffer [ index ] -> m_refCount < 32000 ) m_Buffer [ index ] -> m_refCount ++ ; return m_Buffer [ index ] -> m_Image ; } vresource imageResource ; if ( getResource ( ( char * ) ( * imageName ) , & imageResource ) == 0 ) return NULL ; index = findEmptyCell ( ) ; if ( index < 0 ) { index = findLRUCell ( ) ; delete m_Buffer [ index ] -> m_Image ; delete m_Buffer [ index ] -> m_Name ; delete m_Buffer [ index ] ; m_Buffer [ index ] = NULL ; } m_Buffer [ index ] = new BufferEntry ; m_Buffer [ index ] -> m_Image = new vimage ; m_Buffer [ index ] -> m_Name = new gString ; m_Buffer [ index ] -> m_refCount = 1 ; m_Buffer [ index ] -> m_Image -> Load ( imageResource ) ; ( * m_Buffer [ index ] -> m_Name ) = * imageName ; return m_Buffer [ index ] -> m_Image ; }
loads spesified image from the resource file.
loads spesified image from the resource file .
// maybe image is in the buffer ? // Trying to load specified resource - doing nothing if failed. // looking for the cell to put new image // if there is empty cell ? // if not, we will use LRU cell // removing old data from the cell // Creating new entry in the image buffer.