|
||||
Warning, file /include/root/TToggle.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // @(#)root/meta:$Id$ 0002 // Author: Piotr Golonka 30/07/97 0003 0004 /************************************************************************* 0005 * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. * 0006 * All rights reserved. * 0007 * * 0008 * For the licensing terms see $ROOTSYS/LICENSE. * 0009 * For the list of contributors see $ROOTSYS/README/CREDITS. * 0010 *************************************************************************/ 0011 0012 #ifndef ROOT_TToggle 0013 #define ROOT_TToggle 0014 0015 0016 ////////////////////////////////////////////////////////////////////////// 0017 // // 0018 // TToggle // 0019 // // 0020 // This class defines toggling facility for both - object's method or // 0021 // variables. // 0022 // Assume that user provides an object with a two-state field, and // 0023 // methods to Get/Set value of this field. This object enables to switch// 0024 // values via this method when the only thing you know about the field // 0025 // is the name of the method (or method itself) which sets the field. // 0026 // This facility is required in context popup menu, when the only // 0027 // information about how to toggle a field is a name of method which // 0028 // sets it. // 0029 // This Object may be also used for toggling an integer variable, // 0030 // which may be important while building universal objects... // 0031 // When user provides a "set-method" of name SetXXX this object tries // 0032 // automaticaly to find a matching "get-method" by looking for a method // 0033 // with name GetXXX or IsXXX for given object. // 0034 // // 0035 ////////////////////////////////////////////////////////////////////////// 0036 0037 #include "TNamed.h" 0038 0039 #ifdef R__LESS_INCLUDES 0040 class TMethodCall; 0041 class TMethod; 0042 #else 0043 #include "TMethodCall.h" 0044 #include "TMethod.h" 0045 #endif 0046 0047 class TToggle: public TNamed { 0048 0049 private: 0050 Bool_t fState; //Object's state - "a local copy" 0051 Long_t fOnValue; //Value recognized as switched ON (Def=1) 0052 Long_t fOffValue; //Value recognized as switched OFF(Def=0) 0053 Longptr_t fValue; //Local copy of a value returned by called function 0054 0055 protected: 0056 Bool_t fInitialized; //True if either SetToggledObject or SetToggledVariable called - enables Toggle() method. 0057 TObject *fObject; //The object this Toggle belongs to 0058 TMethodCall *fGetter; //Method to Get a value of fObject; 0059 TMethodCall *fSetter; //Method to Set a value of fObject; 0060 0061 Int_t *fTglVariable; //Alternatively: pointer to an integer value to be Toggled instead of TObjectl 0062 0063 public: 0064 TToggle(); 0065 virtual void SetToggledObject(TObject *obj, TMethod *anymethod); 0066 0067 // you just provide any method which has got an initialized pointer 0068 // to TDataMember... The rest is done automatically... 0069 0070 virtual void SetToggledVariable(Int_t &var); 0071 0072 virtual Bool_t IsInitialized(){ return fInitialized; } 0073 0074 virtual Bool_t GetState(); 0075 virtual void SetState(Bool_t state); 0076 virtual void Toggle(); 0077 0078 virtual void SetOnValue(Long_t lon) { fOnValue=lon; } 0079 virtual Long_t GetOnValue() { return fOnValue; } 0080 virtual void SetOffValue(Long_t lof) { fOffValue=lof; } 0081 virtual Long_t GetOffValue() { return fOffValue; } 0082 0083 virtual Int_t GetValue() { return fValue; } 0084 virtual void SetValue(Long_t val); 0085 0086 TMethodCall *GetGetter() const { return fGetter; } 0087 TMethodCall *GetSetter() const { return fSetter; } 0088 0089 ClassDefOverride(TToggle,0) //Facility for toggling datamembers on/off 0090 }; 0091 0092 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |