Created
May 11, 2024 11:00
-
-
Save nikhil-RGB/b4b83c5e4b964dec99185434667b6853 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:hive_flutter/adapters.dart'; | |
import 'package:turing_machines/models/Behaviour.dart'; | |
import 'package:turing_machines/models/Configuration.dart'; | |
import 'package:turing_machines/models/Tape.dart'; | |
import 'package:turing_machines/models/TuringMachines.dart'; | |
part "TuringMachineModel.g.dart"; | |
@HiveType(typeId: 0) | |
class TuringMachineModel { | |
@HiveField(0) | |
int iterations; | |
@HiveField(1) | |
String initial_config; | |
@HiveField(2) | |
String current_config; | |
@HiveField(3) | |
Tape tape; | |
@HiveField(4) | |
List<Configuration> configs; | |
@HiveField(5) | |
List<Behaviour> behaviours; | |
TuringMachineModel( | |
{required this.iterations, | |
required this.initial_config, | |
required this.current_config, | |
required this.tape, | |
required this.configs, | |
required this.behaviours}); | |
//Factory constructor for Model to save this machine object | |
factory TuringMachineModel.fromMachine({required TuringMachine machine}) { | |
//Construct object from machine object. | |
return TuringMachineModel( | |
iterations: machine.iterations, | |
initial_config: machine.initial_config, | |
current_config: machine.current_config, | |
tape: machine.tape, | |
configs: machine.machine.keys.toList(), | |
behaviours: machine.machine.values.toList()); | |
//LinkedHashMap to List. | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment