StyleSentry.cpp
Go to the documentation of this file.
1 //File: StyleSentry.cpp
2 //Brief: Allows for changes to TStyle that are local to some scope by making a copy
3 // of the old gStyle for changes and restoring back to the original on destruction.
4 // Inspired by how ART's TFileService handles gFile.
5 //Author: Andrew Olivier aolivier@ur.rochester.edu
6 
7 //ROOT includes
8 #include "TStyle.h"
9 
10 namespace util
11 {
12  struct StyleSentry
13  {
14  StyleSentry(): fOldStyle(gStyle)
15  {
16  if(gStyle) gStyle = new TStyle(*gStyle);
17  else gStyle = new TStyle();
18  }
19 
20  ~StyleSentry() { gStyle = fOldStyle; }
21 
22  private:
23  TStyle* fOldStyle; //The old gStyle that will be restored when this object is destroyed
24  };
25 }
Namespace for general, non-LArSoft-specific utilities.