コード例 #1
0
//Create array of type TYPE, versus setAttributeArray that creates a scalar of type array
int ArfFileBase::setAttributeAsArray(DataTypes type, void* data, int size, String path, String name)
{
    H5Location* loc;
    Group gloc;
    DataSet dloc;
    Attribute attr;
    DataType H5type;
    DataType origType;

    if (!opened) return -1;
    try
    {
        try
        {
            gloc = file->openGroup(path.toUTF8());
            loc = &gloc;
        }
        catch (FileIException error) //If there is no group with that path, try a dataset
        {
            dloc = file->openDataSet(path.toUTF8());
            loc = &dloc;
        }

        H5type = getH5Type(type);
        origType = getNativeType(type);

        hsize_t dims = size;

        if (loc->attrExists(name.toUTF8()))
        {
            attr = loc->openAttribute(name.toUTF8());
        }
        else
        {
            DataSpace attr_dataspace(1, &dims); //create a 1d simple dataspace of len SIZE
            attr = loc->createAttribute(name.toUTF8(),H5type,attr_dataspace);
        }

        attr.write(origType,data);

    }
    catch (GroupIException error)
    {
        PROCESS_ERROR;
    }
    catch (AttributeIException error)
    {
        PROCESS_ERROR;
    }
    catch (DataSetIException error)
    {
        PROCESS_ERROR;
    }
    catch (FileIException error)
    {
        PROCESS_ERROR;
    }

    return 0;
}
コード例 #2
0
int HDF5FileBase::setAttributeStr(String value, String path, String name)
{
    H5Location* loc;
    Group gloc;
    DataSet dloc;
    Attribute attr;

    if (!opened) return -1;

    StrType type(PredType::C_S1, value.length());
    try
    {
        try
        {
            gloc = file->openGroup(path.toUTF8());
            loc = &gloc;
        }
        catch (FileIException error) //If there is no group with that path, try a dataset
        {
            dloc = file->openDataSet(path.toUTF8());
            loc = &dloc;
        }

        if (loc->attrExists(name.toUTF8()))
        {
            //attr = loc.openAttribute(name.toUTF8());
            return -1; //string attributes cannot change size easily, better not allow overwritting.
        }
        else
        {
            DataSpace attr_dataspace(H5S_SCALAR);
            attr = loc->createAttribute(name.toUTF8(), type, attr_dataspace);
        }
        attr.write(type,value.toUTF8());

    }
    catch (GroupIException error)
    {
        PROCESS_ERROR;
    }
    catch (AttributeIException error)
    {
        PROCESS_ERROR;
    }
    catch (FileIException error)
    {
        PROCESS_ERROR;
    }
    catch (DataSetIException error)
    {
        PROCESS_ERROR;
    }


    return 0;
}
コード例 #3
0
ファイル: H5DataSet.cpp プロジェクト: CommonLibrary/hdf5
//--------------------------------------------------------------------------
// Function:	DataSet overload constructor - dereference
///\brief	Given a reference, ref, to an hdf5 location, creates a
///		DataSet object
///\param	loc - IN: Dataset reference object is in or location of
///			  object that the dataset is located within.
///\param	ref - IN: Reference pointer
///\param	ref_type - IN: Reference type - default to H5R_OBJECT
///\exception	H5::DataSetIException
///\par Description
///		\c loc can be DataSet, Group, H5File, or named DataType, that
///		is a datatype that has been named by DataType::commit.
// Programmer	Binh-Minh Ribler - Oct, 2006
// Modification
//	Jul, 2008
//		Added for application convenience.
//--------------------------------------------------------------------------
DataSet::DataSet(const H5Location& loc, const void* ref, H5R_type_t ref_type) : AbstractDs(), H5Object(), id(H5I_INVALID_HID)
{
    id = H5Location::p_dereference(loc.getId(), ref, ref_type, "constructor - by dereferenced");
}
コード例 #4
0
ファイル: H5DataType.cpp プロジェクト: MichaelToal/hdf5
//--------------------------------------------------------------------------
// Function:	DataType::commit
///\brief	This is an overloaded member function, kept for backward
///		compatibility.  It differs from the above function in that it
///		misses const's.  This wrapper will be removed in future release.
///\param	loc - IN: A location (file, dataset, datatype, or group)
///\param	name - IN: Name of the datatype
///\exception	H5::DataTypeIException
// Programmer	Binh-Minh Ribler - Jan, 2007
//--------------------------------------------------------------------------
void DataType::commit(H5Location& loc, const H5std_string& name)
{
   p_commit(loc.getId(), name.c_str());
}
コード例 #5
0
ファイル: H5DataType.cpp プロジェクト: MichaelToal/hdf5
//--------------------------------------------------------------------------
// Function:	DataType::commit
///\brief	This is an overloaded member function, kept for backward
///		compatibility.  It differs from the above function in that it
///		misses const's.  This wrapper will be removed in future release.
///\param	loc - IN: A location (file, dataset, datatype, or group)
///\param	name - IN: Name of the datatype
///\exception	H5::DataTypeIException
// Programmer	Binh-Minh Ribler - Jan, 2007
//--------------------------------------------------------------------------
void DataType::commit(H5Location& loc, const char* name)
{
   p_commit(loc.getId(), name);
}
コード例 #6
0
ファイル: H5DataType.cpp プロジェクト: MichaelToal/hdf5
//--------------------------------------------------------------------------
// Function:	DataType overload constructor - dereference
///\brief	Given a reference, ref, to an hdf5 group, creates a
///		DataType object
///\param       loc - IN: Location referenced object is in
///\param	ref - IN: Reference pointer
///\param	ref_type - IN: Reference type - default to H5R_OBJECT
///\param	plist - IN: Property list - default to PropList::DEFAULT
///\exception	H5::ReferenceException
// Programmer	Binh-Minh Ribler - Oct, 2006
// Modification
//	Jul, 2008
//		Added for application convenience.
//--------------------------------------------------------------------------
DataType::DataType(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist) : H5Object()
{
    id = H5Location::p_dereference(loc.getId(), ref, ref_type, plist, "constructor - by dereference");
}
コード例 #7
0
ファイル: H5Location.cpp プロジェクト: Hulalazz/rnnlib
//--------------------------------------------------------------------------
// Function:	H5Location::dereference
///\brief	Dereferences a reference into an HDF5 object, given an HDF5 object.
///\param	loc - IN: Location of the referenced object
///\param	ref - IN: Reference pointer
///\param	ref_type - IN: Reference type
///\param	plist - IN: Property list - default to PropList::DEFAULT
///\exception	H5::ReferenceException
// Programmer	Binh-Minh Ribler - Oct, 2006
// Modification
//	May, 2008
//		Corrected missing parameters. - BMR
//--------------------------------------------------------------------------
void H5Location::dereference(const H5Location& loc, const void* ref, H5R_type_t ref_type, const PropList& plist)
{
   p_setId(p_dereference(loc.getId(), ref, ref_type, plist, "dereference"));
}
コード例 #8
0
//--------------------------------------------------------------------------
// Function:	Group overload constructor - dereference
///\brief	Given a reference, ref, to an hdf5 group, creates a Group object
///\param	loc - IN: Specifying location referenced object is in
///\param	ref - IN: Reference pointer
///\param	ref_type - IN: Reference type - default to H5R_OBJECT
///\exception	H5::ReferenceException
///\par Description
///		\c obj can be DataSet, Group, or named DataType, that
///		is a datatype that has been named by DataType::commit.
// Programmer	Binh-Minh Ribler - Oct, 2006
//--------------------------------------------------------------------------
Group::Group(const H5Location& loc, const void* ref, H5R_type_t ref_type) : H5Object(), id(H5I_INVALID_HID)
{
    id = H5Location::p_dereference(loc.getId(), ref, ref_type, "constructor - by dereference");
}
コード例 #9
0
ファイル: H5Location.cpp プロジェクト: Andy-Sun/VTK
//--------------------------------------------------------------------------
// Function:	H5Location::dereference
///\brief	Dereferences a reference into an HDF5 object, given an HDF5 object.
///\param	loc - IN: Location of the referenced object
///\param	ref - IN: Reference pointer
///\param	ref_type - IN: Reference type
///\param	plist - IN: Property list - default to PropList::DEFAULT
///\exception	H5::ReferenceException
// Programmer	Binh-Minh Ribler - Oct, 2006
// Modification
//	May, 2008
//		Corrected missing parameters. - BMR
//--------------------------------------------------------------------------
void H5Location::dereference(const H5Location& loc, const void* ref, H5R_type_t ref_type)
{
   p_setId(p_dereference(loc.getId(), ref, ref_type, "dereference"));
}
コード例 #10
0
int HDF5FileBase::setAttributeStrArray(Array<const char*>& data, int maxSize, String path, String name)
{
	H5Location* loc;
	Group gloc;
	DataSet dloc;
	Attribute attr;
	hsize_t dims[1];

	if (!opened) return -1;

	StrType type(PredType::C_S1, maxSize + 1);
	type.setSize(H5T_VARIABLE);

	try
	{
		try
		{
			gloc = file->openGroup(path.toUTF8());
			loc = &gloc;
		}
		catch (FileIException error) //If there is no group with that path, try a dataset
		{
			dloc = file->openDataSet(path.toUTF8());
			loc = &dloc;
		}

		if (loc->attrExists(name.toUTF8()))
		{
			//attr = loc.openAttribute(name.toUTF8());
			return -1; //string attributes cannot change size easily, better not allow overwritting.
		}
		else
		{
			DataSpace attr_dataspace;
			int nStrings = data.size();
			if (nStrings > 1)
			{
				dims[0] = nStrings;
				attr_dataspace = DataSpace(1, dims);
			}
			else
				attr_dataspace = DataSpace(H5S_SCALAR);
			attr = loc->createAttribute(name.toUTF8(), type, attr_dataspace);
		}
		attr.write(type, data.getRawDataPointer());

	}
	catch (GroupIException error)
	{
		PROCESS_ERROR;
	}
	catch (AttributeIException error)
	{
		PROCESS_ERROR;
	}
	catch (FileIException error)
	{
		PROCESS_ERROR;
	}
	catch (DataSetIException error)
	{
		PROCESS_ERROR;
	}


	return 0;

}