RCTSL:DEFINE ARRAY CONCEPT TYPE

From Olympus
Jump to: navigation, search
 DEFINE_ARRAY_CONCEPT_TYPE(<element_concept_class>, <array_concept_class>)

Defines the concept type class <array_concept_class> as an array of elements whose class is <element_concept_class>.

Type: concept type definition
Arguments:

  • <element_concept_class>: the concept class of the elements of the array (all elements must be of the same type). For arrays of the standard atomic types, you can use the predefined element classes CBoolConcept, CIntConcept, CFloatConcept, CStringConcept.
  • <array_concept_class>: the name of the created array concept type class.

See also: Concepts in RavenClaw

RavenClaw Task Specification Language Reference


Additional information

The CArrayConcept class is again implemented as an orthogonal-canonic class, having a default and a copy constructor.


CArrayConcept: methods


Somewhat similar to the structured concept types, the CArrayConcept class uses a special method CreateElement for defining arrays of concepts. This method is invoked to create each element in the array, as they are needed. In order to define a new array concept type, the user needs to derive a class from CArrayConcept, and overwrite this virtual method. Again, a macro is provided (DEFINE_ARRAY_CONCEPT_TYPE) for easily accomplishing this task.


For instance, the declaration:


DEFINE_ARRAY_CONCEPT_TYPE(CHotel, CHotelArray)


defines an new array concept type which will hold an array of hotel concepts. CHotel is the type of each individual concept, and ChotelArray is the newly defined type.


The CArrayConcept overwrites the Clear() and Clone() methods, as well as the assignment operators.


CArrayConcept also overwrites the indexing operator [], to allow access to elements of the arra. For instance, if ha is a CHotelArray concept object, then you can access it’s members as hd[0], hd[1], etc. Moreover, accesses to the nested structured/arrays accesses are allowed, so you can access the distance of the first element of the array as as ha[“0.hotel.distance”], and for the second element as ha[“1.hotel.distance”], etc.


The GetSize() virtual method is also overwritten to return the current size of the array.


Also, the confidence related, and the string conversion virtual methods are overwritten by this class to accomplish the right behavior.


The string representation of the value of an array concept (ValueToString) is:

: size {

elem_0_value_to_string

elem_1_value_to_string

. . .

}

So, for the array of hotels, if for instance it would have 3 hotels, the string representation would be


 : 3 {

 {

 hotel {

              distance 0.2

                            price 150

              flag true

 }

  name Hilton

 }

 {

 hotel {

              distance 0.8

                            price 20

              flag true

 }

  name Holiday Inn

 }

 {

 hotel {

              distance 2.5

                            price 150

              flag false
  
 }

 name Sheraton

 }

 }

Personal tools