#ifndef QUERIES_MISALIGNED_TURNOUT_H_
#define QUERIES_MISALIGNED_TURNOUT_H_

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

// pattern misalignedTurnout(location : Segment, train : Train) {
// 	Turnout(turnout);
// 	Segment.occupiedBy(location, train);
// 	Turnout.straight(turnout, location);
// 	neg find connected(location, turnout);
// } or{
// 	Turnout(turnout);
// 	Segment.occupiedBy(location, train);
// 	Turnout.divergent(turnout, location);
// 	neg find connected(location, turnout);
// }

typedef struct _MisalignedTurnoutFrame {
  Segment *location;
  Turnout *turnout;
  Train *train;
} MisalignedTurnoutFrame;

typedef struct _MisalignedTurnoutMatch {
  Segment *location;
  Train *train;
} MisalignedTurnoutMatch;

typedef struct _MisalignedTurnoutMatchSet {
  int size;
  MisalignedTurnoutMatch matches[50];
} MisalignedTurnoutMatchSet;

void misaligned_turnout_matcher(ModelRoot *model, MisalignedTurnoutFrame *frame,
                                int startOpIndex,
                                MisalignedTurnoutMatchSet *results);

#endif // QUERIES_MISALIGNED_TURNOUT_H_
