⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mapfile.cpp

📁 这是在PCA下的基于IPP库示例代码例子,在网上下了IPP的库之后,设置相关参数就可以编译该代码.
💻 CPP
字号:
/* ////////////////////////////////////////////////////////////////////////////                  INTEL CORPORATION PROPRIETARY INFORMATION//     This software is supplied under the terms of a license agreement or//     nondisclosure agreement with Intel Corporation and may not be copied//     or disclosed except in accordance with the terms of that agreement.//          Copyright(c) 2002-2005 Intel Corporation. All Rights Reserved.//////*//*//  This file contains two classes to enclose system routines for//      file opening/closing and for mapping/unmapping view of file in memory//      space. The file mapping in program memory space makes possible the use//      of pointers to access file data, that gives the common way to process//      data by any C functions without explicit data copying.//////*/#include "mapfile.h"#include "diagndescr.h"#include "sysexception.h"File::File() : m_hFile(0) {}File::File(const char *fileName, Access access): m_hFile(0){    Open(fileName, access);}File::~File(){    Close();}void File::Open(const char *fileName, Access access){    Close();    SysAccessRight   sysAccess;    SysCreateOptions createOptions;    switch(access)    {    case NewReadWrite:        sysAccess     = SYS_ACCESS_RIGHT_WRITE | SYS_ACCESS_RIGHT_READ;        createOptions = SYS_CREATE_OPTIONS_ALWAYS_TRUNCATE;        break;    case ReadWrite:        sysAccess     = SYS_ACCESS_RIGHT_WRITE | SYS_ACCESS_RIGHT_READ;        createOptions = SYS_CREATE_OPTIONS_EXISTING_ONLY_KEEP;        break;    case Read:    default:        sysAccess     = SYS_ACCESS_RIGHT_READ;        createOptions = SYS_CREATE_OPTIONS_EXISTING_ONLY_KEEP;        break;    }    sysFileCreate(fileName, sysAccess, createOptions, SYS_ACCESS_TYPE_RANDOM, &m_hFile);    if(m_hFile == 0)    {        switch(access)        {        case NewReadWrite:            throw DIAGN_DESCR_RT(FileException,cannotCreate)(fileName);        case ReadWrite:            throw DIAGN_DESCR_RT(FileException,cannotOpenOrCreate)(fileName);        case Read:        default:            throw DIAGN_DESCR_RT(FileException,cannotOpen)(fileName);        }    }}void File::Close(){    sysFileClose(m_hFile);    m_hFile = 0;}unsigned int File::Size() const{    unsigned int size;    sysFileGetSize(m_hFile, &size);    return size;}MapFile::MapFile() : m_hMap(0), m_hMapView(0) {}MapFile::MapFile(const char *fileName): m_hMap(0), m_hMapView(0){    Open(fileName);}MapFile::MapFile(const char *fileName, int size): m_hMap(0), m_hMapView(0){    Open(fileName, size);}MapFile::~MapFile(){    Close();}void MapFile::Open(const char *fileName){    Close();    m_file.Open(fileName, File::Read);    sysMemoryMapCreate(m_file, SYS_MEMORY_MAP_ACCESS_READ_WRITE_COPY, Size(), &m_hMap);    if(!m_hMap)        throw DIAGN_DESCR_RT(MapFileException,cannotCreateMapping)(fileName);    sysMemoryMapViewCreate(m_hMap, SYS_MEMORY_MAP_ACCESS_READ_WRITE_COPY, 0, Size(), &m_hMapView);    if(!m_hMapView)    {        sysMemoryMapClose(m_hMap);        throw DIAGN_DESCR_RT(MapFileException,cannotMapView)(fileName);    }}void MapFile::Open(const char *fileName, int size){    Close();    m_file.Open(fileName, File::NewReadWrite);    sysMemoryMapCreate(m_file, SYS_MEMORY_MAP_ACCESS_READ_WRITE, size, &m_hMap);    if(!m_hMap)        throw DIAGN_DESCR_RT(MapFileException,cannotCreateMapping)(fileName);    sysMemoryMapViewCreate(m_hMap, SYS_MEMORY_MAP_ACCESS_READ_WRITE, 0, size, &m_hMapView);    if(!m_hMapView)    {        sysMemoryMapClose(m_hMap);        throw DIAGN_DESCR_RT(MapFileException,cannotMapView)(fileName);    }}void MapFile::Close(){    m_file.Close();    sysMemoryMapViewClose(m_hMapView); m_hMapView = 0;    sysMemoryMapClose    (m_hMap);     m_hMap     = 0;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -