All Downloads are FREE. Search and download functionalities are using the official Maven repository.

swim.runtime.scope.LaneScope Maven / Gradle / Ivy

There is a newer version: 3.10.0
Show newest version
// Copyright 2015-2019 SWIM.AI inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package swim.runtime.scope;

import swim.api.downlink.EventDownlink;
import swim.api.downlink.ListDownlink;
import swim.api.downlink.MapDownlink;
import swim.api.downlink.ValueDownlink;
import swim.api.http.HttpDownlink;
import swim.api.ref.LaneRef;
import swim.concurrent.Stage;
import swim.runtime.CellContext;
import swim.runtime.downlink.EventDownlinkView;
import swim.runtime.downlink.MapDownlinkView;
import swim.runtime.downlink.ValueDownlinkView;
import swim.structure.Form;
import swim.structure.Value;
import swim.uri.Uri;
import swim.warp.CommandMessage;

public class LaneScope extends Scope implements LaneRef {
  protected final Uri meshUri;
  protected final Uri hostUri;
  protected final Uri nodeUri;
  protected final Uri laneUri;

  public LaneScope(CellContext cellContext, Stage stage, Uri meshUri,
                   Uri hostUri, Uri nodeUri, Uri laneUri) {
    super(cellContext, stage);
    this.meshUri = meshUri;
    this.hostUri = hostUri;
    this.nodeUri = nodeUri;
    this.laneUri = laneUri;
  }

  public final Uri meshUri() {
    return this.meshUri;
  }

  @Override
  public final Uri hostUri() {
    return this.hostUri;
  }

  @Override
  public final Uri nodeUri() {
    return this.nodeUri;
  }

  @Override
  public final Uri laneUri() {
    return this.laneUri;
  }

  @Override
  public EventDownlink downlink() {
    return new EventDownlinkView(this, stage, this.meshUri, this.hostUri, this.nodeUri,
        this.laneUri, 0.0f, 0.0f, Value.absent(), Form.forValue());
  }

  @Override
  public ListDownlink downlinkList() {
    return null; // TODO
  }

  @Override
  public MapDownlink downlinkMap() {
    return new MapDownlinkView(this, stage, this.meshUri, this.hostUri,
        this.nodeUri, this.laneUri, 0.0f, 0.0f, Value.absent(), Form.forValue(), Form.forValue());
  }

  @Override
  public ValueDownlink downlinkValue() {
    return new ValueDownlinkView(this, stage, this.meshUri, this.hostUri, this.nodeUri,
        this.laneUri, 0.0f, 0.0f, Value.absent(), Form.forValue());
  }

  @Override
  public  HttpDownlink downlinkHttp() {
    return null; // TODO
  }

  @Override
  public void command(float prio, Value body) {
    final CommandMessage message = new CommandMessage(this.nodeUri, this.laneUri, body);
    pushDown(new ScopePushRequest(this.meshUri, this.hostUri, null, message, prio));
  }

  @Override
  public void command(Value body) {
    command(0.0f, body);
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy