File: DFSA.h

package info (click to toggle)
magnus 20060324-5.1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 19,436 kB
  • ctags: 20,462
  • sloc: cpp: 130,217; ansic: 37,090; tcl: 10,970; perl: 1,109; makefile: 966; sh: 403; yacc: 372; csh: 57; awk: 33; asm: 10
file content (112 lines) | stat: -rw-r--r-- 4,342 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
// Copyright (C) 1994 The New York Group Theory Cooperative
// See magnus/doc/COPYRIGHT for the full notice.

// Contents: The deterministic finite state automaton class
//
// Principal Author: Sarah Rees
//
// Status: in progress
//
// Revision History:
//

#ifndef DFSA_H_
#define DFSA_H_

#include "FSA.h"
#include "DFSARep.h"

class DFSA : public FSA {
typedef DFSARep::State State;
public:
// constructors for DFSA.
// Name is only needed for input/output, and may be set to "" (in which 
// case a non-empty but meaningless string will be assigned for output.

  DFSA( ) : FSA( new DFSARep() ) { }

  DFSA(const VectorOf<Chars> & genNames) : FSA( new DFSARep("",genNames) ) { }

  DFSA(Chars name,const VectorOf<Chars> & genNames) 
     : FSA( new DFSARep(name,genNames) ) { }

  DFSA( const VectorOf<Chars> & genNames, int numOfStates) 
     : FSA( new DFSARep("",genNames, numOfStates,1) ) { }

  DFSA( const Chars & Name, const VectorOf<Chars> & genNames, int numOfStates) 
     : FSA( new DFSARep(Name, genNames, numOfStates,1) ) { }

  DFSA( const VectorOf<Chars> & genNames, int numOfStates, int numOfStrings) 
     : FSA( new DFSARep("", genNames, numOfStates, numOfStrings ) ) { }

  DFSA( const Chars & Name, const VectorOf<Chars> & genNames, int numOfStates, int numOfStrings) 
     : FSA( new DFSARep(Name, genNames, numOfStates, numOfStrings ) ) { }

  State target(State s,Generator g) const { return look()->target(s,g);}
  int getNumStates() const { return look()->getNumStates();}

protected:
  DFSA( DFSARep * rep ) : FSA((FSARep *)rep) { }
  // Need to shadow inherited look() and change(), to get right ptr types.
  const DFSARep *look() const { return (DFSARep*)FSA::look(); }
  DFSARep *change() { return (DFSARep*)FSA::change(); }
};

class GroupDFSA : public FSA {
// A GroupDFSA is a DFSA for which the alphabet is actually the set of
// all symbols of the listed alphabet together with their formal
// inverses. Transits are defined on symbols and their inverses,
// and words in those symbols with both positive and negative exponents
// may be read in.
// This class should be used if the symbols of the FSA are the generators
//(and their inverses) of a finitely generated group.

friend class DiffMachineRep;
typedef DFSARep::State State;

public:
// constructors for GroupDFSA.
  GroupDFSA( ) : FSA( new GroupDFSARep() ) { }

  GroupDFSA(const VectorOf<Chars> & genNames) 
     : FSA( new GroupDFSARep("",genNames) ) { }

  GroupDFSA(const VectorOf<Chars> & genNames, const WordOrder & word_order) 
     : FSA( new GroupDFSARep("",genNames, word_order) ) { }


  GroupDFSA(Chars name,const VectorOf<Chars> & genNames) 
     : FSA( new GroupDFSARep(name,genNames) ) { }

  GroupDFSA(Chars name,const VectorOf<Chars> & genNames,
                                             const WordOrder & word_order) 
     : FSA( new GroupDFSARep(name,genNames,word_order) ) { }

  GroupDFSA( const Chars & Name, const VectorOf<Chars> & genNames, int numOfStates) 
     : FSA( new GroupDFSARep(Name, genNames, numOfStates,1) ) { }

  GroupDFSA( const VectorOf<Chars> & genNames, const WordOrder & word_order,
                                                             int numOfStates) 
     : FSA( new GroupDFSARep("",genNames, word_order,numOfStates,1) ) { }

  GroupDFSA( const VectorOf<Chars> & genNames, int numOfStates, int numOfStrings) 
     : FSA( new GroupDFSARep("", genNames, numOfStates, numOfStrings ) ) { }

  GroupDFSA( const VectorOf<Chars> & genNames, const WordOrder & word_order,
                                            int numOfStates, int numOfStrings) 
     : FSA( new GroupDFSARep("", genNames, word_order, 
                                    numOfStates, numOfStrings ) ) { }

  GroupDFSA( const Chars & Name, const VectorOf<Chars> & genNames, int numOfStates, int numOfStrings) 
     : FSA( new GroupDFSARep(Name, genNames, numOfStates, numOfStrings ) ) { }
  State target(State s,Generator g) const { return look()->target(s,g);}
  int getNumStates() const { return look()->getNumStates();}

protected:
  GroupDFSA( GroupDFSARep * rep ) : FSA((FSARep *)rep) { }
  // Need to shadow inherited look() and change(), to get right ptr types.
  const GroupDFSARep *look() const { return (GroupDFSARep*)FSA::look(); }
  GroupDFSARep *change() { return (GroupDFSARep*)FSA::change(); }
};

#endif