SourceTraits.h
Go to the documentation of this file.
1 #ifndef art_Framework_IO_Sources_SourceTraits_h
2 #define art_Framework_IO_Sources_SourceTraits_h
3 ////////////////////////////////////////////////////////////////////////
4 // SourceTraits
5 //
6 // Attributes controlling the behavior of Source with respect to a
7 // particular detail class.
8 //
9 // Specialize as required.
10 //
11 // Generally speaking, type traits are simple struct or class templates
12 // whose purpose is to signal (at compile time) one or more properties
13 // of another type, specified as the (usually only) template
14 // argument. The property to be signalled may be a compile-time
15 // expression in the template, set explicitly, or (more rarely) left
16 // unspecified. One is expected to specialize the trait for your own
17 // types in order to convey the intended information about them.
18 ////////////////////////////////////
19 // Available traits.
20 //
21 // Specialize the following traits for your source detail class if you
22 // wish to tune the behavior of your InputSource:
23 //
24 // 1. Source_generator.
25 //
26 // If art::Source_generator<MyClass>::value is true, it indicates that
27 // your source detail class MyClass does not read files or otherwise use
28 // the input string provided to it in its readFile(...)
29 // function. Defaults to false; specialize to true for your detail class
30 // XXXX as below:
31 //
32 // namespace art {
33 // template<>
34 // struct Source_generator<XXXX> {
35 // static constexpr bool value = true;
36 // };
37 // }
38 //
39 // 2. Source_wantFileServices.
40 //
41 // If art::Source_wantFileServices<MyClass>::value is false you are
42 // representing that your source detail class MyClass will be working
43 // from the list of filenames provided by the FHiCL parameter
44 // source.fileNames, but does not want them treated as real files by the
45 // standard service interfaces (CatalogInterface and FileTransfer). Use
46 // this if source.fileNames is a list of URLS for streaming data, for
47 // instance. Absent specialization,
48 // art::Source_wantFileServices<MyClass>::value is defined as the
49 // logical negation of art::Source_generator<MyClass>::value (see
50 // above); specialize as you wish.
51 //
52 ////////////////////////////////////////////////////////////////////////
53 namespace art {
54  // We are a generator, not a reader (or, we read our data from
55  // somewhere other than files specified by source.fileNames).
56  template <typename DETAIL>
58  static constexpr bool value = false;
59  };
60 
61  // Use the standard service interfaces (CatalogInterface and
62  // FileTransfer) to obtain files.
63  template <typename DETAIL>
65  // If you're a generator, you almost certainly don't want to use the
66  // standard file services.
67  static constexpr bool value = !Source_generator<DETAIL>::value;
68  };
69 
70 } // namespace art
71 
72 #endif /* art_Framework_IO_Sources_SourceTraits_h */
73 
74 // Local Variables:
75 // mode: c++
76 // End:
static constexpr bool value
Definition: SourceTraits.h:58