atlas
Library.h
1 /*
2  * (C) Copyright 2013 ECMWF.
3  *
4  * This software is licensed under the terms of the Apache Licence Version 2.0
5  * which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
6  * In applying this licence, ECMWF does not waive the privileges and immunities
7  * granted to it by virtue of its status as an intergovernmental organisation
8  * nor does it submit to any jurisdiction.
9  */
10 
11 #pragma once
12 
13 #include <iosfwd>
14 #include <memory>
15 #include <string>
16 
17 #include "eckit/filesystem/PathName.h"
18 #include "eckit/system/Library.h"
19 #include "eckit/system/Plugin.h"
20 
21 namespace eckit {
22 class Parametrisation;
23 class PathName;
24 } // namespace eckit
25 
26 namespace atlas {
27 
28 namespace mpi {
29 void finalise();
30 void finalize();
31 } // namespace mpi
32 
33 void initialise( int argc, char** argv );
34 void initialize( int argc, char** argv );
35 void initialise();
36 void initialize();
37 void finalise();
38 void finalize();
39 
40 //----------------------------------------------------------------------------------------------------------------------
41 
42 class Library : public eckit::system::Library {
43 public:
44  static Library& instance();
45 
46  virtual std::string version() const override;
47 
48  virtual std::string gitsha1( unsigned int count ) const override;
49  std::string gitsha1() const { return gitsha1( 7 ); }
50 
51  void initialise( int argc, char** argv );
52  void initialise( const eckit::Parametrisation& );
53  void initialise();
54  void finalise();
55 
56  struct Information {
57  friend std::ostream& operator<<( std::ostream& s, const Information& i ) {
58  i.print( s );
59  return s;
60  }
61  void print( std::ostream& ) const;
62  };
63  Information information() const { return Information(); }
64 
65  virtual eckit::Channel& infoChannel() const;
66  virtual eckit::Channel& warningChannel() const;
67  virtual eckit::Channel& traceChannel() const;
68  virtual eckit::Channel& debugChannel() const override;
69  bool trace() const { return trace_; }
70  virtual bool debug() const override { return debug_; }
71 
72  bool traceBarriers() const { return trace_barriers_; }
73  bool traceMemory() const { return trace_memory_; }
74 
75  Library();
76 
77  void registerPlugin( eckit::system::Plugin& );
78  void deregisterPlugin( eckit::system::Plugin& );
79  const std::vector<eckit::system::Plugin*>& plugins() { return plugins_; }
80 
81  std::string cachePath() const;
82  std::string dataPath() const;
83 
84  void registerDataPath( const std::string& );
85 
86 protected:
87  virtual const void* addr() const override;
88 
89  bool debug_{false};
90  bool info_{true};
91  bool warning_{true};
92  bool trace_{false};
93  bool trace_memory_{false};
94  bool trace_barriers_{false};
95  bool trace_report_{false};
96  mutable std::unique_ptr<eckit::Channel> info_channel_;
97  mutable std::unique_ptr<eckit::Channel> warning_channel_;
98  mutable std::unique_ptr<eckit::Channel> trace_channel_;
99  mutable std::unique_ptr<eckit::Channel> debug_channel_;
100 
101 private:
102  std::vector<eckit::system::Plugin*> plugins_;
103  std::vector<std::string> data_paths_;
104 };
105 
106 using Atlas = Library;
107 
108 //----------------------------------------------------------------------------------------------------------------------
109 
110 } // namespace atlas
Definition: Domain.h:19
Contains all atlas classes and methods.
Definition: atlas-grids.cc:33
Definition: Library.h:56
Definition: Library.h:42