00001 #ifndef SAMPLE_HANDLER_SAMPLE_HANDLER_HH
00002 #define SAMPLE_HANDLER_SAMPLE_HANDLER_HH
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include <SampleHandler/Global.h>
00015
00016 #include <memory>
00017 #include <iosfwd>
00018 #include <map>
00019 #include <vector>
00020 #include <TObject.h>
00021
00022 namespace SH
00023 {
00035 std::string dbg (const SampleHandler& obj, unsigned verbosity = 0);
00036
00037
00043 void swap (SampleHandler& a, SampleHandler& b);
00044
00045
00046
00054 class SampleHandler : public TObject
00055 {
00056
00057
00058
00059
00064 public:
00065 void testInvariant () const;
00066
00067
00074 public:
00075 SampleHandler ();
00076
00077
00084 public:
00085 SampleHandler (const SampleHandler& that);
00086
00087
00092 public:
00093 ~SampleHandler ();
00094
00095
00102 public:
00103 SampleHandler& operator = (const SampleHandler& that);
00104
00105
00114 public:
00115 void add (Sample *sample);
00116
00117
00127 public:
00128 void add (std::unique_ptr<Sample> sample);
00129
00130
00140 public:
00141 void add (const SamplePtr& sample);
00142
00143
00152 public:
00153 void add (const SampleHandler& sh);
00154
00155
00164 public:
00165 void addWithPrefix (const SampleHandler& sh, const std::string& prefix);
00166
00167
00175 public:
00176 void remove (const std::string& name);
00177
00178
00187 public:
00188 void remove (Sample *sample);
00189
00190
00199 public:
00200 Sample *get (const std::string& name) const;
00201
00202
00211 public:
00212 SampleHandler find (const TagList& tags) const;
00213
00214
00225 public:
00226 SampleHandler find (const std::string& tags) const;
00227
00228
00240 public:
00241 Sample *findBySource (const std::string& name) const;
00242
00243
00253 public:
00254 SampleHandler findByName (const std::string& pattern) const;
00255
00256
00264 public:
00265 void print () const;
00266
00267
00277 public:
00278 void printContent () const;
00279
00280
00292 public:
00293 void save (const std::string& directory) const;
00294
00295
00307 public:
00308 void load (const std::string& directory);
00309
00310
00324 public:
00325 void updateLocation (const std::string& from, const std::string& to);
00326
00327
00339 public:
00340 void fetch (const SampleHandler& source);
00341
00342
00352 public:
00353 void fetchDefaults (const SampleHandler& source);
00354
00355
00369 public:
00370 bool check_complete (const SampleHandler& source) const;
00371
00372
00385 public:
00386 void setMetaDouble (const std::string& name, double value);
00387
00388
00401 public:
00402 void setMetaString (const std::string& name, const std::string& value);
00403
00404
00419 public:
00420 void setMetaDouble (const std::string& pattern, const std::string& name,
00421 double value);
00422
00423
00438 public:
00439 void setMetaString (const std::string& pattern, const std::string& name,
00440 const std::string& value);
00441
00442
00444 public:
00445 typedef std::vector<Sample*>::const_iterator iterator;
00446
00447
00452 public:
00453 iterator begin () const;
00454
00455
00460 public:
00461 iterator end () const;
00462
00463
00468 public:
00469 std::size_t size () const;
00470
00471
00477 public:
00478 Sample *operator [] (std::size_t index) const;
00479
00480
00486 public:
00487 Sample *at (std::size_t index) const;
00488
00489
00490
00491
00492
00493
00494
00495 friend void swap (SampleHandler& a, SampleHandler& b);
00496
00498 private:
00499 std::vector<SH::Sample*> m_samples;
00500
00502 private:
00503 typedef std::vector<SH::Sample*>::const_iterator SamplesIter;
00504
00506 private:
00507 typedef std::vector<SH::Sample*>::iterator SamplesMIter;
00508
00510 private:
00511 std::map<std::string,SH::SamplePtr> m_named;
00512
00514 private:
00515 typedef std::map<std::string,SH::SamplePtr>::const_iterator NamedIter;
00516
00518 private:
00519 typedef std::map<std::string,SH::SamplePtr>::iterator NamedMIter;
00520
00521 ClassDef (SampleHandler, 1)
00522 };
00523 }
00524
00525 #endif