Metadatas are one of the basic object in Atoms. They are wrapper around basic data types and they hinerit the basic object AtomsCore::Metadata.
The basic Metadata class has function to clone, copy, serialize etc.. to abstract the data type.
These are the basic metadata type that can be used inside Atoms:
- BoolMetadata
- BoolArrayMetadata
- IntMetadata
- IntArrayMetadata
- DoubleMetadata
- DoubleArrayMetadata
- Vector3Metadata
- Vector3ArrayMetadata
- QuaternionMetadata
- QuaternionArrayMetadata
- MatrixMetadata
- MatrixArrayMetadata
- CurveMetadata
- CurveArrayetadata
- MeshMetadata
- MeshArrayMetadata
- ImageMetadata
- PoseMetadata
- SkeletonMetadata
These are container metadata data type:
- MapMetadata
- ArrayMetadata
Creating metadatas
You can create metadata using the normal constructor of each type or you can use the metadata factory. Every metadata type as a unique typeId, it's used to register the metadata inside he metadata factory. Since the serialization code rely on this factory.
AtomsCore::IntMetadata intMeta(5); AtomsCore::DoubleMetadata doubleMeta(654.4); AtomsCore::MetadataFactory& factory = AtomsCore::MetadataFactory::instance(); AtomsPtr<AtomsCore::Metadata> data = factory.createMetadata(AtomsCore::Vector3Metadata::staticTypeId());
MapMetada
The MapMetadata is a map container for metadata. It can store different type od metadata at the same time. It uses strings as key.
To insert data inside a MapMetadata use the addEntry function. This function can clone the input metadata or store directly the input smart pointer, increasing the reference conunter.
AtomsCore::MapMetadata mapMeta; // Insert element cloning the data mapMeta.addEnetry("myKey1", &AtomsCore::IntMetadata(4)); AtomsPtr<AtomsCore::DoubleMetadata> doubleMeta(new AtomsCore::DoubleMetadata(5.7)); // Insert element cloning the data mapMeta.addEntry("myKey2", std::static_pointer_cast<AtomsCore::Metadata>(doubleMeta), true); AtomsPtr<AtomsCore::Vector3Metadata> vecMeta(new AtomsCore::Vector3Metadata(AtomsCore::Vector3(1,0,0)); // Insert element without cloning, copying the smart pointer and increasing the reference counter mapMeta.addEntry("myKey3", std::static_pointer_cast<AtomsCore::Metadata>(vecMeta), false);
To get an entry from the map, use the getEntry or getTypedEntry function
AtomsPtr<AtomsCore::Vector3Metadata> vecData = mapMeta.getTypedEntry<AtomsCore::Vector3Metadata>("myKey3"); AtomsPtr<Metadata> intData = mapMeta.getEntry("myKey1");
ArrayMetadata
The array metadata si similar to the mapmetadata but it store metadata in a vector rather than a map.