#ifndef QUERIES_END_OF_SIDING_H_
#define QUERIES_END_OF_SIDING_H_

// pattern endOfSiding(train : Train, location : Segment) {
//   Segment.train(location, train);
//   Segment.connectedTo(end, location);
//   1 == count find connected(end, _);
// }

#include "model_root.h"
#include "segment.h"
#include "train.h"

typedef struct _EndOfSidingFrame {
  Segment *location;
  Segment *end;
  Train *train;
} EndOfSidingFrame;

typedef struct _EndOfSidingMatch {
  Segment *location;
  Train *train;
} EndOfSidingMatch;

typedef struct _EndOfSidingMatchSet {
  int size;
  EndOfSidingMatch matches[50];
} EndOfSidingMatchSet;

void end_of_siding_matcher(ModelRoot *model, EndOfSidingFrame *frame,
                           int startOpIndex, EndOfSidingMatchSet *results);

#endif // QUERIES_END_OF_SIDING_H_
