Scopira 20080306

view.h

00001 
00002 /*
00003  *  Copyright (c) 2004    National Research Council
00004  *
00005  *  All rights reserved.
00006  *
00007  *  This material is confidential and proprietary information of
00008  *  National Research Council Canada ("Confidential Information").
00009  *  This Confidential Information may only be used and reproduced
00010  *  in accordance with the terms of the license agreement.
00011  *
00012  */
00013 
00014 #ifndef __INCLUDED_SCOPIRA_CORE_VIEW_H__
00015 #define __INCLUDED_SCOPIRA_CORE_VIEW_H__
00016 
00017 #include <string>
00018 
00019 #include <scopira/tool/object.h>
00020 #include <scopira/tool/export.h>
00021 
00022 namespace scopira
00023 {
00024   namespace core
00025   {
00026     class view_action_reactor_i;
00027     class view_container_reactor_i;
00028 
00029     class view_i;
00030 
00031     class model_i; //fwd
00032 
00040     SCOPIRA_EXPORT void bind_model_view(scopira::core::model_i *m, scopira::core::view_i *v);
00041   }
00042 }
00043 
00044 // internal handler interface
00045 class scopira::core::view_action_reactor_i
00046 {
00047   public:
00048     SCOPIRA_EXPORT virtual ~view_action_reactor_i() { }
00049     SCOPIRA_EXPORT virtual void react_view_action(scopira::core::view_i *source, int actionID) = 0;
00050     SCOPIRA_EXPORT virtual void react_view_set_title(scopira::core::view_i *source, const std::string &newtitle) = 0;
00051 };
00052 
00059 class scopira::core::view_container_reactor_i
00060 {
00061   public:
00062     SCOPIRA_EXPORT virtual ~view_container_reactor_i() { }
00071     SCOPIRA_EXPORT virtual void react_view_insert(scopira::core::model_i *m, scopira::core::view_i *v) = 0;
00072 };
00073 
00080 class scopira::core::view_i : public virtual scopira::tool::object
00081 {
00082   private:
00083     view_action_reactor_i *dm_action_handler;
00084     std::string dm_pretitle;  //used if we get title change requests before we actually have a listener
00085 
00086   public:
00094     SCOPIRA_EXPORT virtual void bind_model(scopira::core::model_i *sus);
00096     SCOPIRA_EXPORT virtual void react_model_update(scopira::core::model_i *sus, scopira::core::view_i *src);
00097 
00099     SCOPIRA_EXPORT void set_view_action_reactor(view_action_reactor_i *vh);
00100 
00101   protected:
00102     SCOPIRA_EXPORT view_i(void);
00103 
00105     SCOPIRA_EXPORT void react_view_action(int actionID);
00106 
00108     SCOPIRA_EXPORT void set_view_title(const std::string &newtitle);
00109 };
00110 
00111 inline void scopira::core::bind_model_view(scopira::core::model_i *m, scopira::core::view_i *v)
00112 {
00113   v->bind_model(m);
00114   v->react_model_update(m, 0);
00115 }
00116 
00117 #endif
00118