Skip to content

Commit 4ce21e0

Browse files
Update README.md with the latest Typedefinition (#57)
1 parent ae41fff commit 4ce21e0

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

README.md

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -101,29 +101,28 @@ You can also register a custom type, as shown in the example below.
101101
#include "data_tamer/sinks/mcap_sink.hpp"
102102
#include "data_tamer/custom_types.hpp"
103103

104-
// a custom type
104+
// This is your custom type
105+
namespace MyNamespace
106+
{
105107
struct Point3D
106108
{
107109
double x;
108110
double y;
109111
double z;
110112
};
113+
} // end namespace MyNamespace
111114

112-
namespace DataTamer
113-
{
114-
template <> struct TypeDefinition<Point3D>
115+
// You must implement the function TypeDefinition in the same namespace as Point3D
116+
namespace MyNamespace
115117
{
116-
// Provide the name of the type
117-
std::string typeName() const { return "Point3D"; }
118-
// List all the member variables that you want to be saved (including their name)
119-
template <class Function> void typeDef(Function& addField)
120-
{
121-
addField("x", &Point3D::x);
122-
addField("y", &Point3D::y);
123-
addField("z", &Point3D::z);
124-
}
118+
template <typename AddField>
119+
std::string_view TypeDefinition(Point3D& point, AddField& add) {
120+
add("x", &point.x);
121+
add("y", &point.y);
122+
add("z", &point.z);
123+
return "Point3D";
125124
}
126-
} // end namespace DataTamer
125+
} // end namespace MyNamespace
127126

128127
int main()
129128
{

0 commit comments

Comments
 (0)