"Fossies" - the Fresh Open Source Software Archive

Member "ivtools-ivtools-2.0.4/src/include/InterViews/action.h" (9 Oct 2020, 3133 Bytes) of package /linux/misc/ivtools-ivtools-2.0.4.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "action.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  * Copyright (c) 1987, 1988, 1989, 1990, 1991 Stanford University
    3  * Copyright (c) 1991 Silicon Graphics, Inc.
    4  *
    5  * Permission to use, copy, modify, distribute, and sell this software and 
    6  * its documentation for any purpose is hereby granted without fee, provided
    7  * that (i) the above copyright notices and this permission notice appear in
    8  * all copies of the software and related documentation, and (ii) the names of
    9  * Stanford and Silicon Graphics may not be used in any advertising or
   10  * publicity relating to the software without the specific, prior written
   11  * permission of Stanford and Silicon Graphics.
   12  * 
   13  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, 
   14  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY 
   15  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  
   16  *
   17  * IN NO EVENT SHALL STANFORD OR SILICON GRAPHICS BE LIABLE FOR
   18  * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
   19  * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
   20  * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF 
   21  * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE 
   22  * OF THIS SOFTWARE.
   23  */
   24 
   25 /*
   26  * Action - something to do
   27  */
   28 
   29 #ifndef iv_action_h
   30 #define iv_action_h
   31 
   32 #include <InterViews/resource.h>
   33 
   34 #include <InterViews/_enter.h>
   35 
   36 class Action : public Resource {
   37 protected:
   38     Action();
   39     virtual ~Action();
   40 public:
   41     virtual void execute() = 0;
   42 };
   43 
   44 /*
   45  * Macro - list of actions
   46  */
   47 
   48 typedef long MacroIndex;
   49 
   50 class MacroActionList;
   51 
   52 class Macro : public Action {
   53 public:
   54     Macro(Action* = nil, Action* = nil, Action* = nil, Action* = nil);
   55     virtual ~Macro();
   56 
   57     virtual void prepend(Action*);
   58     virtual void append(Action*);
   59     virtual void insert(MacroIndex, Action*);
   60     virtual void remove(MacroIndex);
   61 
   62     virtual MacroIndex count() const;
   63     virtual Action* action(MacroIndex) const;
   64 
   65     virtual void execute();
   66 private:
   67     MacroActionList* list_;
   68 };
   69 
   70 /*
   71  * Action denoted by an object and member function to call on the object.
   72  */
   73 
   74 #if defined(__STDC__) || defined(__ANSI_CPP__)
   75 #define __ActionCallback(T) T##_ActionCallback
   76 #define ActionCallback(T) __ActionCallback(T)
   77 #define __ActionMemberFunction(T) T##_ActionMemberFunction
   78 #define ActionMemberFunction(T) __ActionMemberFunction(T)
   79 #else
   80 #define __ActionCallback(T) T/**/_ActionCallback
   81 #define ActionCallback(T) __ActionCallback(T)
   82 #define __ActionMemberFunction(T) T/**/_ActionMemberFunction
   83 #define ActionMemberFunction(T) __ActionMemberFunction(T)
   84 #endif
   85 
   86 #define declareActionCallback(T) \
   87 typedef void (T::*ActionMemberFunction(T))(); \
   88 class ActionCallback(T) : public Action { \
   89 public: \
   90     ActionCallback(T)(T*, ActionMemberFunction(T)); \
   91 \
   92     virtual void execute(); \
   93 private: \
   94     T* obj_; \
   95     ActionMemberFunction(T) func_; \
   96 };
   97 
   98 #define implementActionCallback(T) \
   99 ActionCallback(T)::ActionCallback(T)(T* obj, ActionMemberFunction(T) func) { \
  100     obj_ = obj; \
  101     func_ = func; \
  102 } \
  103 \
  104 void ActionCallback(T)::execute() { (obj_->*func_)(); }
  105 
  106 #include <InterViews/_leave.h>
  107 
  108 #endif