ViewModeChangeMulticaster.java
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008, AIST, the University of Tokyo and General Robotix Inc.
3  * All rights reserved. This program is made available under the terms of the
4  * Eclipse Public License v1.0 which accompanies this distribution, and is
5  * available at http://www.eclipse.org/legal/epl-v10.html
6  * Contributors:
7  * General Robotix Inc.
8  * National Institute of Advanced Industrial Science and Technology (AIST)
9  */
10 package com.generalrobotix.ui.view.tdview;
11 
13  protected ViewModeChangeListener listener1_, listener2_;
14 
16  ViewModeChangeListener listener1,
17  ViewModeChangeListener listener2
18  ) {
19  listener1_ = listener1;
20  listener2_ = listener2;
21  }
22 
23  public void viewModeChanged(int mode) {
24  listener1_.viewModeChanged(mode);
25  listener2_.viewModeChanged(mode);
26  }
27 
28  public static ViewModeChangeListener add(
29  ViewModeChangeListener listener1,
30  ViewModeChangeListener listener2
31  ) {
32  if (listener1 == null) return listener2;
33  if (listener2 == null) return listener1;
34  return new ViewModeChangeMulticaster(listener1, listener2);
35  }
36 
37  public static ViewModeChangeListener remove(
38  ViewModeChangeListener listener,
40  ) {
41  if (listener == old || listener == null) {
42  return null;
43  } else if (listener instanceof ViewModeChangeMulticaster) {
44  return ((ViewModeChangeMulticaster)listener).remove(old);
45  } else {
46  return listener;
47  }
48  }
49 
50  protected ViewModeChangeListener remove(ViewModeChangeListener listener) {
51  if (listener == listener1_) return listener2_;
52  if (listener == listener2_) return listener1_;
53  ViewModeChangeListener listener1 = remove(listener1_, listener);
54  ViewModeChangeListener listener2 = remove(listener2_, listener);
55  if (listener1 == listener1_ && listener2 == listener2_) {
56  return this;
57  }
58  return add(listener1, listener2);
59  }
60 }
#define null
our own NULL pointer
Definition: IceTypes.h:57
static ViewModeChangeListener add(ViewModeChangeListener listener1, ViewModeChangeListener listener2)
ViewModeChangeMulticaster(ViewModeChangeListener listener1, ViewModeChangeListener listener2)


openhrp3
Author(s): AIST, General Robotix Inc., Nakamura Lab of Dept. of Mechano Informatics at University of Tokyo
autogenerated on Sat May 8 2021 02:42:41