1 //
2 //  CoreViewListener.h
3 //  avida/apps/viewer-macos
4 //
5 //  Created by David Bryson on 11/11/10.
6 //  Copyright 2010-2011 Michigan State University. All rights reserved.
7 //  http://avida.devosoft.org/viewer-macos
8 //
9 //  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
10 //  following conditions are met:
11 //
12 //  1.  Redistributions of source code must retain the above copyright notice, this list of conditions and the
13 //      following disclaimer.
14 //  2.  Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
15 //      following disclaimer in the documentation and/or other materials provided with the distribution.
16 //  3.  Neither the name of Michigan State University, nor the names of contributors may be used to endorse or promote
17 //      products derived from this software without specific prior written permission.
18 //
19 //  THIS SOFTWARE IS PROVIDED BY MICHIGAN STATE UNIVERSITY AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20 //  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 //  DISCLAIMED. IN NO EVENT SHALL MICHIGAN STATE UNIVERSITY OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 //  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23 //  SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
24 //  WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
25 //  USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 //
27 //  Authors: David M. Bryson <david@programerror.com>
28 //
29 
30 #import <Foundation/Foundation.h>
31 
32 #include "avida/viewer-core/Listener.h"
33 
34 @class CoreViewMap;
35 @class CoreViewUpdate;
36 
37 namespace Avida {
38   namespace CoreView {
39     class Map;
40   };
41 };
42 
43 
44 @protocol CoreViewListener
45 @property (readonly) Avida::CoreView::Listener* listener;
46 @optional
47 - (void) handleMap:(CoreViewMap*)pkg;
48 - (void) handleUpdate:(CoreViewUpdate*)pkg;
49 @end
50 
51 
52 @interface CoreViewMap : NSObject {
53   Avida::CoreView::Map* m_map;
54 }
55 - (id) initWithMap:(Avida::CoreView::Map*)map;
56 @property (readonly) Avida::CoreView::Map* map;
57 @end;
58 
59 
60 @interface CoreViewUpdate : NSObject {
61   int m_update;
62 }
63 - (id) initWithUpdate:(int)update;
property(readonly)64 @property (readonly) int update;
65 @end
66 
67 
68 class MainThreadListener : public Avida::CoreView::Listener
69 {
70 private:
71   id m_target;
72 
73 public:
74   MainThreadListener(id <CoreViewListener> target) : m_target(target) { ; }
75 
76   bool WantsMap() { return true; }
77   bool WantsUpdate() { return true; }
78 
79   void NotifyMap(Avida::CoreView::Map* map);
80   void NotifyUpdate(int update);
81 };
82