|
| Type () |
| Default constructor. More...
|
|
| Type (TClass *cls) |
| Construct for a class type. More...
|
|
| Type (EDataType type) |
| Construct for a fundamental type. More...
|
|
| Type (const std::string &typname) |
| Construct from a type name. More...
|
|
| Type (const RootUtils::Type &other) |
| Copy constructor. More...
|
|
Type & | operator= (const RootUtils::Type &other) |
| Assignment. More...
|
|
| ~Type () |
| Destructor. More...
|
|
void | init (const std::string &typname) |
| Initialize from a type name. More...
|
|
void | init (TClass *cls) |
| Initialize for a class type. More...
|
|
void | init (EDataType type) |
| Initialize for a fundamental data type. More...
|
|
void * | create () const |
| Create an instance of the object. More...
|
|
void | destroy (void *p) const |
| Destroy an instance of the object (and free memory). More...
|
|
std::string | getTypeName () const |
| Return the name of this type. More...
|
|
const TClass * | getClass () const |
| Return the ROOT class for the described type. More...
|
|
EDataType | getDataType () const |
| Return the ROOT data type code for the described type. More...
|
|
const std::type_info * | getTypeInfo () const |
| Return the type_info for the described type. More...
|
|
size_t | getSize () const |
| Return the size in bytes of an instance of the described type. More...
|
|
void | copyRange (void *dst, const void *src, size_t n) const |
| Copy a range of objects. More...
|
|
void | clearRange (void *dst, size_t n) const |
| Clear a range of objects. More...
|
|
void | clearRange (void *dst, size_t index, size_t n) const |
| Clear a range of objects. More...
|
|
void | clear (void *dst, size_t index) const |
| Clear an object in a vector. More...
|
|
void | clear (void *dst) const |
| Clear an object. More...
|
|
void | assign (void *dst, size_t dst_index, const void *src, size_t src_index) const |
| Copy an object within vectors. More...
|
|
void | assign (void *dst, const void *src) const |
| Copy an object. More...
|
|
void | swap (void *a, size_t a_index, void *b, size_t b_index) const |
| Swap an object between vectors. More...
|
|
void | swap (void *a, void *b) const |
| Swap two objects. More...
|
|
void | swapRange (void *a, size_t a_index, void *b, size_t b_index, size_t n) const |
| Swap a range of objects between vectors. More...
|
|
void | fromString (void *p, const std::string &s) const |
| Initialize an object from a string. More...
|
|
Wrapper for ROOT types.
Using the ROOT interfaces to manipulate objects of generic type is rather awkward, because you have do to completely different things depending on whether the type of object you're dealing with is a class or a fundamental type. This wrapper allows treating these two cases in a uniform way. For now, we don't try to handle other kinds of types (pointers, etc).
Definition at line 39 of file Type.h.
RootUtils::Type::Type |
( |
| ) |
|
Default constructor.
Wrapper for ROOT types.
The only thing you can do with the resulting object is to call init()
on it.
Using the ROOT interfaces to manipulate objects of generic type is rather awkward, because you have do to completely different things depending on whether the type of object you're dealing with is a class or a fundamental type. This wrapper allows treating these two cases in a uniform way. For now, we don't try to handle other kinds of types (pointers, etc).
Definition at line 35 of file Type.cxx.
void RootUtils::Type::init |
( |
const std::string & |
type_name | ) |
|
Initialize from a type name.
- Parameters
-
typname | The name of the type. |
The Type
object must have been just default-constructed.
typname
may be either the name of a fundamental type, or the name of a class known to ROOT. An exception will be thrown if the name is not recognized.
- Parameters
-
type_name | The name of the type. |
The Type
object must have been just default-constructed.
type_name
may be either the name of a fundamental type, or the name of a class known to ROOT. An exception will be thrown if the name is not recognized.
Definition at line 154 of file Type.cxx.
158 gROOT->GetListOfTypes();
162 TClass*
cls = TClass::GetClass (type_name.c_str());
168 for (
int i = 0;
i < kNumDataTypes; ++
i) {
169 EDataType
type =
static_cast<EDataType
>(
i);
170 TDataType*
dt = TDataType::GetDataType(
type);
171 if (
dt && type_name ==
dt->GetTypeName()) {
177 EDataType
type = kNoType_t;
181 if( type_name.rfind(
"std::", 0) == 0 ) {
183 tname = type_name.substr(5);
187 if (tname ==
"uint32_t") {
188 if (
sizeof (
unsigned int) == 4)
191 else if (tname ==
"int32_t") {
192 if (
sizeof (
unsigned int) == 4)
195 else if (tname ==
"uint16_t") {
196 if (
sizeof (
unsigned short) == 2)
199 else if (tname ==
"int16_t") {
200 if (
sizeof (
short) == 2)
203 else if (tname ==
"uint8_t") {
206 else if (tname ==
"int8_t") {
209 else if (tname ==
"uint64_t") {
210 if (
sizeof(
unsigned long) == 8)
212 else if (
sizeof(
unsigned long long) == 8)
216 else if (tname ==
"int64_t") {
217 if (
sizeof(
long) == 8)
219 else if (
sizeof(
long long) == 8)
223 if (
type != kNoType_t) {
228 throw std::runtime_error (std::string (
"RootUtils::Type: Can't find type `") +