-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Template return-type functions for reading data? #216
Comments
Here is another example of boilerplate that could potentially be a one-liner
Yes, it's not as efficient as allocating everything at the beginning of the universe, but reality dictates many such situations as, for example, the above being from some unit tests that validate small datasets. |
We definitely should have something like this and it is already planned. What we have to do for that purpose is to refacture the type trait framework we currently use for IO. What we would need in particular is a type trait that tells the library how to create an instance of a particular type. template<typename T> class FactoryTrait
{
public:
static T create(const hdf5::dataspace::Dataspace &space,
const hdf5::datatype::Datatype &type);
} With this in our arsenal it would be rather straight forward to do things like the above. I have a very rough design in mind which would do the job. But it still requires some rethinking. I hope I can put a draft online for discussion this week. |
I have attempted to do something like template<typename T>
T read() const
{
T ret;
read(ret);
return ret;
} but this only works for scalar values, not vectors, as it needs to resize them before writing. Any idea how to do this so it would work for both? Would this FactoryTrait really help? |
As for the discusion with Jan on #379 the first step to make this happen is to add the following static member to the dataspace trait namespace hdf5 {
namespace dataspace {
template<typename T> class TypeTrait<T>
public:
// create a new instance of T according to dataspace
static T allocate(const Dataspace &dataspace)
{
}
};
}
} |
There is a fairly stale branch for this issue: https://github.com/ess-dmsc/h5cpp/tree/issue_280 |
I do not see this branch and the link is dead. Is this something you still have around on your machine? |
Sorry, I must have pasted the wrong link. I deleted the branch for the closed ticket #280 that had nothing that isn't in master. Nothing to do with this one. The branch for this ticket is https://github.com/ess-dmsc/h5cpp/tree/issue_216 |
This branch can be definitely removed. No objections on that. But we should leave this ticket open. |
Could we have instead of:
this:
Just an idea
The text was updated successfully, but these errors were encountered: