Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Current »

Metadatas are one of the basic entities in Atoms. They wrap basic data types and inherit the basic object AtomsCore.Metadata.

The basic Metadata class has functions to clone, copy, serialize etc.

These are the basic metadata type that can be used inside Atoms:

  • BoolMetadata
  • BoolArrayMetadata
  • IntMetadata
  • IntArrayMetadata
  • DoubleMetadata
  • DoubleArrayMetadata
  • Vector3Metadata
  • Vector3ArrayMetadata
  • EulerMetadata
  • EulerArrayMetadata
  • QuaternionMetadata
  • QuaternionArrayMetadata
  • MatrixMetadata
  • MatrixArrayMetadata
  • CurveMetadata
  • CurveArrayetadata
  • MeshMetadata
  • MeshArrayMetadata
  • ImageMetadata
  • PoseMetadata
  • SkeletonMetadata

These are container metadata types:

  • MapMetadata
  • ArrayMetadata

Creating metadatas

You can create metadatas using the constructor of each type or you can use the metadata factory. Every metadata type has a unique typeId, it's used to register the metadata inside the metadata factory. Since the serialization code relies on this factory.

import AtomsCore
intMeta = AtomsCore.IntMetadata(5)
doubleMeta = AtomsCore.DoubleMetadata(654.4)

factory = AtomsCore.MetadataFactory.instance()
data = factory.createMetadata(AtomsCore.Vector3Metadata.staticTypeId())

MapMetada

The MapMetadata is a map container for metadatas. It can store different metadata types at the same time. It uses strings as keys.

To insert data inside a MapMetadata:

import AtomsCore
mapMeta = AtomsCore.MapMetadata()
#Insert element cloning the data
mapMeta["myKey1"] = AtomsCore.IntMetadata(4)

To get an entry from the map:

vecData = mapMeta["myKey3"]
intData = mapMeta["myKey1"]

ArrayMetadata

The array metadata is similar to the MapMetadata but it stores metadata in a vector rather than a map.

All the metadata types and some other Atoms objects can be serialized/deserialized to and from the disk.

To serialize an object you need to create an archive object and use the serialize functions or the << operator.

AtomsCore::DoubleMetadata doubleMeta(5.6);

AtomsCore::Archive archive(doubleMeta.memSize());
archive << doubleMeta;
// or
doubleMeta.serialize(archive);

AtomsCore::IntMetadata intMeta(8);
AtomsCore::MapMetadata mapMeta;
mapMeta.addEntry("key1", &doubleMeta);
mapMeta.addEntry("key2", &intMeta);
AtomsCore::Archive archiveMap(mapMeta.memSize());
mapMeta.serialise(archiveMap);
archiveMap.writeToFile("myArchive.atoms")


To deserialize use the deserialise functions or the >> operator

AtomsCore::MapMetadata mapMeta;
AtomsCore::Archive archiveMap;
if (archiveMap.readFromFile("myArchive.atoms"))
{
	mapMeta.deserialise(archiveMap);
}

  • No labels