Skip to content
Snippets Groups Projects
Commit bd88fc2c authored by Philippe Canal's avatar Philippe Canal
Browse files

Introduce TKey::ReadObject<typeName>. This is a user friendly wrapper around ReadObjectAny.

parent 1f36a37c
No related branches found
No related tags found
No related merge requests found
......@@ -65,6 +65,14 @@ In extremely rare cases, this change breaks a valid use where the temporary `TSt
object before the destruction of the temporary: `TString str = objStr->GetString().ReplaceAll("a", "b");`. In these rare cases,
please use the new function `CopyString()` which clearly indicates that it involves a temporary.
## I/O Libraries
- Introduce TKey::ReadObject<typeName>. This is a user friendly wrapper around ReadObjectAny. For example
```{.cpp}
auto h1 = key->ReadObject<TH1>
```
after which h1 will either be null if the key contains something that is not a TH1 (or derived class)
or will be set to the address of the histogram read from the file.
## Histogram Libraries
......@@ -94,9 +102,6 @@ please use the new function `CopyString()` which clearly indicates that it invol
## Geometry Libraries
## I/O Libraries
## Database Libraries
......
......@@ -15,8 +15,8 @@
#include "TNamed.h"
#include "TDatime.h"
#include "TBuffer.h"
#include "TClass.h"
class TClass;
class TBrowser;
class TDirectory;
class TFile;
......@@ -93,6 +93,12 @@ protected:
virtual Int_t Read(TObject *obj);
virtual TObject *ReadObj();
virtual TObject *ReadObjWithBuffer(char *bufferRead);
/// To read an object (non deriving from TObject) from the file.
/// This is more user friendly version of TKey::ReadObjectAny.
/// See TKey::ReadObjectAny for more details.
template <typename T> T *ReadObject() {
return reinterpret_cast<T*>(ReadObjectAny(TClass::GetClass(typeid(T))));
}
virtual void *ReadObjectAny(const TClass *expectedClass);
virtual void ReadBuffer(char *&buffer);
void ReadKeyBuffer(char *&buffer);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment