Pteros  2.0
Molecular modeling library for human beings!
consumer_base.h
1 /*
2  *
3  * This source code is part of
4  * ******************
5  * *** Pteros ***
6  * ******************
7  * molecular modeling library
8  *
9  * Copyright (c) 2009-2013, Semen Yesylevskyy
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of Artistic License:
13  *
14  * Please note, that Artistic License is slightly more restrictive
15  * then GPL license in terms of distributing the modified versions
16  * of this software (they should be approved first).
17  * Read http://www.opensource.org/licenses/artistic-license-2.0.php
18  * for details. Such license fits scientific software better then
19  * GPL because it prevents the distribution of bugged derivatives.
20  *
21 */
22 
23 #ifndef CONSUMER_BASE_H
24 #define CONSUMER_BASE_H
25 
26 #include "pteros/core/system.h"
27 #include "pteros/analysis/frame_info.h"
28 #include <fstream>
29 #include <iostream>
30 #include <memory>
31 
32 template<class T>
33 class Message_channel;
34 
35 namespace pteros {
36 
43 };
44 
45 // Forward declarations
47 
56  friend class Trajectory_processor;
57 public:
59 
60  System* get_system(){return &system;}
61  void set_id(int i){id = i;}
62 
63 protected:
65  virtual void pre_process();
67  virtual void post_process(const Frame_info& info);
69  virtual void process_frame(const Frame_info& info);
71  virtual void window_started(const Frame_info& info);
73  virtual void window_finished(const Frame_info& info);
74 
76  System system;
79 
83  virtual void pre_process_handler(){
84  pre_process();
85  }
86 
87  virtual void post_process_handler(const Frame_info& info){
88  post_process(info);
89  }
90 
91  virtual void process_frame_handler(const Frame_info& info){
92  process_frame(info);
93  }
94 
95  virtual void window_started_handler(const Frame_info& info){
96  window_started(info);
97  }
98 
99  virtual void window_finished_handler(const Frame_info& info){
100  window_finished(info);
101  }
102 
103 private:
104 
106  int id;
108  int win_num;
109  float win_start_time;
110  int win_start_frame;
111 
112  // Should be defined in derived classes
113  virtual void process_frame_data(Frame& data) = 0;
114 
115  float saved_time; //Save last processed timestamp
116  int saved_abs_frame;
117  int saved_valid_frame;
118 
119  void run_in_thread(std::shared_ptr<Message_channel<std::shared_ptr<Data_container> > >& chan);
120  void consume_frame(std::shared_ptr<Data_container>& data);
121 };
122 
123 }
124 
125 #endif
Frame frame
Frame itself.
Definition: consumer_base.h:40
Definition of single trajectory frame.
Definition: system.h:67
Pteros namespace.
Definition: options.cpp:32
The system of atoms.
Definition: system.h:95
The base class for trajectory processing It provides facilities for loading large trajectories by fra...
Definition: trajectory_processor.h:43
Information about current frame, which is passed to Consumer for analysis along with the frame itself...
Definition: frame_info.h:31
Base class for asynchronous data analysis.
Definition: consumer_base.h:55
Frame_info frame_info
Frame information.
Definition: consumer_base.h:42
Auxiliary container for sending data to consumers.
Definition: consumer_base.h:38