LArSoft  v06_85_00
Liquid Argon Software toolkit - http://larsoft.org/
CurrentProcessingContext.h
Go to the documentation of this file.
1 #ifndef art_Framework_Principal_CurrentProcessingContext_h
2 #define art_Framework_Principal_CurrentProcessingContext_h
3 
4 // CurrentProcessingContext is a class that carries information about
5 // the current event processing context. Each module in a framework
6 // job can access its CurrentProcessingContext *when that module is
7 // active in event processing*. At such a time, the
8 // CurrentProcessingContext will provide information about that
9 // module's place in the schedule, *as seen at that moment*.
10 //
11 // N.B.: An individual module instance can appear in more than one
12 // path; this is why CurrentProcessingContext reports the module's
13 // place in the schedule as seen at the time of execution. This is
14 // also why the module can not be queried for this information when
15 // it is not active in processing.
16 
18 
19 #include <cstddef>
20 #include <string>
21 
22 // ----------------------------------------------------------------------
23 
24 namespace art {
25  class ModuleDescription;
26 }
27 
29 public:
30  // Default-constructed objects reflect the inactive state.
32 
33  // Create a CurrentProcessingContext ready to handle the Path
34  // with given name and bit position (slot in Schedule).
35  CurrentProcessingContext(std::string const* name, int bitpos, bool isEndPth);
36 
37  // The compiler-generated copy c'tor and d'tor are correct,
38  // because all our resources are contained by value. We do not
39  // own the resources to which we point; we own only the pointers.
40 
41  // Return the address of the moduleLabel if the module is active,
42  // and null otherwise.
43  std::string const* moduleLabel() const;
44 
45  // Return the name of the current path if the module is active,
46  // and null otherwise.
47  std::string const* pathName() const;
48 
49  // Return the address of the ModuleDescription describing this
50  // module if active, and null otherwise.
51  ModuleDescription const* moduleDescription() const;
52 
53  // Return the slot number of this path in the schedule (this is
54  // the bit position of the path) if the path is active, and -1
55  // otherwise.
56  int pathInSchedule() const;
57 
58  // Return the slot number of this module in the path if the path
59  // is active, and -1 otherwise.
60  int slotInPath() const;
61 
62  // Return true if the path is an end path, and false otherwise.
63  bool isEndPath() const;
64 
65  // Set the context to reflect the active state.
66  void activate(std::size_t theSlotInPath, ModuleDescription const* mod);
67 
68  // Set all data to reflect inactive state.
69  void deactivate();
70 
71 private:
72  // N.B.: We own none of the pointed-to resources!
74  std::size_t slotInPath_;
76  std::string const* pathName_;
77  bool isEndPath_;
78 
79  bool
80  is_active() const
81  {
82  return moduleDescription_ != 0;
83  }
84 }; // CurrentProcessingContext
85 
86 #endif /* art_Framework_Principal_CurrentProcessingContext_h */
87 
88 // Local Variables:
89 // mode: c++
90 // End:
ModuleDescription const * moduleDescription() const
ModuleDescription const * moduleDescription_
std::string const * pathName() const
void activate(std::size_t theSlotInPath, ModuleDescription const *mod)
std::string const * moduleLabel() const
HLT enums.