Scopira  20080306
sidekick.h
1 
2 /*
3  * Copyright (c) 2005 National Research Council
4  *
5  * All rights reserved.
6  *
7  * This material is confidential and proprietary information of
8  * National Research Council Canada ("Confidential Information").
9  * This Confidential Information may only be used and reproduced
10  * in accordance with the terms of the license agreement.
11  *
12  */
13 
14 #ifndef __INCLUDED_SCOPIRA_CORE_SIDEKICK_H__
15 #define __INCLUDED_SCOPIRA_CORE_SIDEKICK_H__
16 
17 #include <scopira/tool/export.h>
18 #include <scopira/tool/thread.h>
19 #include <scopira/tool/object.h>
20 
21 namespace scopira
22 {
23  namespace core
24  {
25  class sidekick_i;
26  class sidekick_reactor_i;
27 
28  class sidekick_queue_i;
29 
39  SCOPIRA_EXPORT void enqueue_sidekick(sidekick_i *t, sidekick_reactor_i *reac = 0);
40 
49  SCOPIRA_EXPORT bool is_sidekick_running(void);
50  }
51 }
52 
62  public virtual scopira::tool::runnable_i
63 {
64  public:
65  protected:
67  sidekick_i(void) : dm_treact(0) { }
68 
74  SCOPIRA_EXPORT void notify_reactors(void);
75 
77  //virtual void run(void);
78 
79  protected:
80  // in the future, make a class sidekick_msg_window that allows
81  // a window to be open the whole time during the run.
82  // ... allow output too?
83  // ... allow cancelability?
84  // bah, make them use core?
85 
86  private:
87  sidekick_reactor_i *dm_treact;
88 
91 };
92 
99 {
100  public:
101  virtual ~sidekick_reactor_i() { }
110  SCOPIRA_EXPORT virtual void react_sidekick_notify(sidekick_i *t) = 0;
119  SCOPIRA_EXPORT virtual void react_sidekick_done(sidekick_i *t) = 0;
120 };
121 
128 {
129  protected:
131  SCOPIRA_EXPORT sidekick_queue_i(void);
133  SCOPIRA_EXPORT virtual ~sidekick_queue_i();
134 
136  SCOPIRA_EXPORT virtual void enqueue_sidekick(sidekick_i *t) = 0;
138  SCOPIRA_EXPORT virtual bool is_sidekick_running(void) = 0;
139 
141  sidekick_reactor_i * & get_reactor(sidekick_i &sk) { return sk.dm_treact; }
142 
143  protected:
145  SCOPIRA_EXPORT static sidekick_queue_i *dm_instance;
146 
148  friend bool scopira::core::is_sidekick_running(void);
149 };
150 
151 // impls are in sidekickthread
152 
319 #endif
320 
Definition: sidekick.h:127
bool is_sidekick_running(void)
Definition: archiveflow.h:20
static sidekick_queue_i * dm_instance
static instance variable
Definition: sidekick.h:145
Definition: sidekick.h:98
Definition: object.h:71
Definition: thread_pthreads.h:69
sidekick_i(void)
ctor
Definition: sidekick.h:67
void enqueue_sidekick(sidekick_i *t, sidekick_reactor_i *reac=0)
Definition: sidekick.h:61
sidekick_reactor_i *& get_reactor(sidekick_i &sk)
helper to get around friend functionenss
Definition: sidekick.h:141