#ifndef QUERIES_CLOSE_TRAINS_H_
#define QUERIES_CLOSE_TRAINS_H_

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

// pattern closeTrains(start : Segment, end : Segment) {
//   Train.location(train, start);
//   Segment.connectedTo(start, middle);
//   Segment.connectedTo(middle, end);
//   start != end;
//   Segment.train(end, otherTrain);
// }

typedef struct _CloseTrainsFrame {
  Segment *start;
  Segment *middle;
  Segment *end;
  Train *t1;
  Train *t2;
} CloseTrainsFrame;

typedef struct _CloseTrainsMatch {
  Segment *start;
  Segment *end;
} CloseTrainsMatch;

typedef struct _CloseTrainsMatchSet {
  int size;
  CloseTrainsMatch matches[100];
} CloseTrainsMatchSet;

void close_trains_matcher(ModelRoot *model, CloseTrainsFrame *frame,
                          int startOpIndex, CloseTrainsMatchSet *results);

#endif /* QUERIES_CLOSE_TRAINS_H_ */
