Changeset 23 for ruby/trunk/models/am/archetype/constraint_model
- Timestamp:
- May 1, 2008, 8:21:09 AM (16 years ago)
- Location:
- ruby/trunk/models/am/archetype/constraint_model
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
ruby/trunk/models/am/archetype/constraint_model/archetype_constraint.rb
r21 r23 8 8 end 9 9 10 class C _OBJECT < ARCHETYPE_CONSTRAINT10 class CARDINALITY 11 11 12 12 end 13 13 14 class C_OBJECT < ARCHETYPE_CONSTRAINT 15 attr_accessor :node_id, :occurrences, :rm_type_name 16 17 def initialize(args = { }) 18 @node_id = args[:node_id] if args[:node_id] 19 @occurrences = args[:occurrences] if args[:occurrences] 20 @rm_type_name = args[:rm_type_name] if args[:rm_type_name] 21 end 22 end 23 14 24 class C_ATTRIBUTE < ARCHETYPE_CONSTRAINT 15 25 attr_accessor :rm_attribute_name, :existence, :children 26 27 def initialize(args = { }) 28 @rm_attribute_name = args[:rm_attribute_name] if args[:rm_attribute_name] 29 @existence = args[:existence] if args[:existence] 30 @children = args[:children] ? args[:children] : [] 31 32 end 16 33 end 17 34 18 35 class C_DEFINED_OBJECT < C_OBJECT 36 attr_accessor :assumed_value 19 37 38 def initialize(args = { }) 39 @assumed_value = args[:assumed_value] if args[:assumed_value] 40 super 41 end 20 42 end 21 43 22 44 class C_PRIMITIVE_OBJECT < C_DEFINED_OBJECT 45 attr_accessor :item 23 46 47 def initialize(args = { }) 48 @attributes = args[:item] if args[:item] 49 super 50 end 24 51 end 25 52 … … 27 54 attr_accessor :attributes, :attributes_valid 28 55 56 def initialize(args = { }) 57 @attributes = args[:attributes] ? args[:attributes] : [] 58 super 59 end 60 61 def self.create(args = { }, &block) 62 c_complex_object = new(args) 63 if block_given? 64 yield c_complex_object 65 end 66 return c_complex_object 67 end 29 68 end 30 69 … … 49 88 end 50 89 90 class C_SINGLE_ATTRIBUTE < C_ATTRIBUTE 91 attr_accessor :alternatives 92 93 def initialize(args = { }) 94 @alternatives = args[:alternatives] ? args[:alternatives] : [] 95 super 96 end 97 end 98 99 class C_MULTIPLE_ATTRIBUTE < C_ATTRIBUTE 100 attr_accessor :members, :cardinality 101 102 def initialize(args = { }) 103 @members = args[:members] ? args[:members] : [] 104 @cardinality = args[:cardinality] if args[:cardinality] 105 super 106 end 107 end 51 108 end 52 109 end -
ruby/trunk/models/am/archetype/constraint_model/assertion.rb
r4 r23 2 2 module AM 3 3 module Archetype 4 module Constraint_Model 5 module Assertion 6 class Assertion 7 end 4 module Assertion 5 class ASSERTION 6 end 7 8 class ASSERTION_VARIABLE 9 end 10 11 class OPERATOR_KIND 12 end 13 14 class EXPR_ITEM 15 end 16 17 class EXPR_LEAF < EXPR_ITEM 18 end 19 20 class EXPR_OPERATOR < EXPR_ITEM 21 end 22 23 class EXPR_UNARY_OPERATOR < EXPR_OPERATOR 24 end 25 26 class EXPR_BINARY_OPERATOR < EXPR_OPERATOR 8 27 end 9 28 end -
ruby/trunk/models/am/archetype/constraint_model/primitive.rb
r21 r23 6 6 module Primitive 7 7 8 class C_P rimitive8 class C_PRIMITIVE 9 9 def assumed_value 10 10 raise NotImplementedError, "assumed_value should be implemented" … … 21 21 end 22 22 23 class C_Boolean < C_Primitive 24 attr_accessor :assumed_value 25 def initialize(true_valid, false_valid, assumed_value) 26 binary_consistency(true_valid, false_valid) 27 @true_valid = true_valid 28 @false_valid = false_valid 29 @assumed_value = assumed_value 23 class C_BOOLEAN < C_PRIMITIVE 24 attr_reader :true_valid, :false_valid, :assumed_value 25 26 def initialize(args = { }) 27 @true_valid = args[:true_valid] ? args[:true_valid] : false 28 @false_valid = args[:false_valid] ? args[:false_valid] : false 29 @assumed_value = args[:assumed_value] ? args[:assumed_value] : false 30 binary_consistency(@true_valid, @false_valid) 30 31 end 31 def set_true_valid(true_valid) 32 33 def true_valid=(true_valid) 32 34 binary_consistency(true_valid, @false_valid) 33 35 @true_valid = true_valid 34 36 end 35 def set_false_valid(false_valid) 37 38 def false_valid=(false_valid) 36 39 binary_consistency(@true_valid,false_valid) 37 40 @false_valid = false_valid 38 41 end 39 def true_valid? 40 @true_valid 41 end 42 def false_valid? 43 @false_valid 44 end 42 45 43 def valid_value? 46 44 47 45 end 48 def default_value(a_value=nil) 46 47 def default_value(a_value = nil) 49 48 if a_value == nil 50 49 @true_valid … … 63 62 end # of C_Boolean 64 63 65 class C_ Integer < C_Primitive64 class C_STRING < C_PRIMITIVE 66 65 67 66 end 67 68 class C_INTEGER < C_PRIMITIVE 69 70 end 71 72 class C_REAL < C_PRIMITIVE 73 74 end 75 76 class C_TIME < C_PRIMITIVE 77 78 end 79 80 class C_DATE < C_PRIMITIVE 81 82 end 83 84 class C_DATE_TIME < C_PRIMITIVE 85 86 end 87 88 class C_DURATION < C_PRIMITIVE 89 90 end 91 92 93 68 94 end # of Primitive 69 95 end # of Constraint_Model
Note:
See TracChangeset
for help on using the changeset viewer.