Logo ROOT   6.14/05
Reference Guide
TIOFeatures.hxx
Go to the documentation of this file.
1 // Author: Brian Bockelman UNL 09/2017
2 
3 /*************************************************************************
4  * Copyright (C) 1995-2017, Rene Brun and Fons Rademakers. *
5  * All rights reserved. *
6  * *
7  * For the licensing terms see $ROOTSYS/LICENSE. *
8  * For the list of contributors see $ROOTSYS/README/CREDITS. *
9  *************************************************************************/
10 
11 #ifndef ROOT_TIO_FEATURES
12 #define ROOT_TIO_FEATURES
13 
14 #include "TBasket.h"
15 
16 #include <initializer_list>
17 #include <memory>
18 #include <string>
19 #include <sstream>
20 #include <typeinfo>
21 #include <type_traits> // is_same, enable_if
22 
23 namespace ROOT {
24 
25 
26 // These are the known, supported, and enabled-by-default features for ROOT IO.
27 //
28 // Note that the `kSupported` members for EIOFeatures, Experimental::EIOFeatures, and
29 // Experiment::EIOUnsupportedFeatures should have no intersection and a union of equal
30 // to BITS(kIOFeatureCount).
31 //
32 enum class EIOFeatures {
33  kSupported = 0 // Union of all known, supported, and enabled-by-default features (currently none).
34 };
35 
36 
37 namespace Experimental {
38 
39 // These are the known and supported "experimental" features, not enabled by default.
40 // When these are enabled by default, they will move to `ROOT::EIOFeatures`.
41 //
42 // Note that these all show up in TBasket::EIOBits, but it is desired to have the enum be at
43 // the "ROOT-IO-wide" level and not restricted to TBasket -- even if all the currently-foreseen
44 // usage of this mechanism somehow involves baskets currently.
45 enum class EIOFeatures {
47  kSupported = kGenerateOffsetMap // Union of all features in this enum.
48 };
49 
50 
51 // These are previous experimental features that are not supported in this series.
52 // NOTE: the intent is that there is never an IO feature that goes into the ROOT:: namespace
53 // but is unsupported.
55  kUnsupported = 0 // Union of all features in this enum.
56 };
57 
58 
59 } // namespace Experimental
60 
61 
62 class TIOFeatures {
63 friend class ::TTree;
64 friend class ::TBranch;
65 friend class ::TBasket;
66 
67 public:
69 
70  void Clear(EIOFeatures bits);
71  void Clear(Experimental::EIOUnsupportedFeatures bits);
72  void Clear(Experimental::EIOFeatures bits);
73  bool Set(EIOFeatures bits);
74  bool Set(Experimental::EIOFeatures bits);
75  bool Set(const std::string &);
76  bool Test(EIOFeatures bits) const;
77  bool Test(Experimental::EIOFeatures bits) const;
78  bool Test(Experimental::EIOUnsupportedFeatures bits) const;
79  void Print() const;
80 
81  // The number of known, defined IO features (supported / unsupported / experimental).
82  static constexpr int kIOFeatureCount = 1;
83 
84 private:
85  // These methods allow access to the raw bitset underlying
86  // this object, breaking type safety. They are necessary for
87  // efficient interaction with TTree / TBranch / TBasket, but left
88  // private to prevent users from interacting with the raw bits.
89  TIOFeatures(UChar_t IOBits) : fIOBits(IOBits) {}
90  UChar_t GetFeatures() const;
91  void Set(UChar_t newBits) {fIOBits = newBits;}
92 
93  UChar_t fIOBits{0};
94 };
95 
96 } // namespace ROOT
97 
98 #endif // ROOT_TIO_FEATURES
Namespace for new ROOT classes and functions.
Definition: StringConv.hxx:21
#define BIT(n)
Definition: Rtypes.h:78
TIOFeatures provides the end-user with the ability to change the IO behavior of data written via a TT...
Definition: TIOFeatures.hxx:62
void Set(UChar_t newBits)
Definition: TIOFeatures.hxx:91
void Print(std::ostream &os, const OptionType &opt)
TIOFeatures(UChar_t IOBits)
Definition: TIOFeatures.hxx:89
unsigned char UChar_t
Definition: RtypesCore.h:34