
# Turbine data abstraction layer

namespace eval turbine {

    namespace export                      \
        string_init string_set string_get \
        file_init   file_set   file_get

    proc string_init { id } {
        adlb::create $id "string:"
        turbine::c::declare $id
    }

    proc string_set { id value } {
        close_dataset $id "string:$value"
    }

    proc string_get { id } {
        puts "get $id"
        set s [ adlb::retrieve $id ]
        set i [ string first : $s ]
        set result [ string range $s $i end ]
        return $result
    }

    proc file_init { id path } {
        adlb::create $id "file:$path"
        turbine::c::declare $id
    }

    proc file_set { id } {
        close_dataset $id "file:close"
    }

    proc file_get { id } {
        puts "get $id"
        set s [ adlb::retrieve $id ]
        set i [ file first : $s ]
        set result [ file range $s $i end ]
        return $result
    }

    proc close_dataset { id value } {
        global WORK_TYPE
        adlb::store $id $value
        set ranks [ adlb::close $id ]
        foreach rank $ranks {
            puts "notify: $rank"
            adlb::put $rank $WORK_TYPE(CONTROL) "close $id"
        }
    }
}


# Turbine data abstraction layer

namespace eval turbine {

    namespace export                      \
        string_init string_set string_get \
        file_init   file_set   filename

    proc string_init { id } {
        adlb::create $id "string:"
        turbine::c::declare $id
    }

    proc string_set { id value } {
        close_dataset $id "string:$value"
    }

    proc string_get { id } {
        puts "get $id"
        set s [ adlb::retrieve $id ]
        set i [ string first : $s ]
        set result [ string range $s $i end ]
        return $result
    }

    proc file_init { id path } {
        adlb::create $id "file:$path"
        turbine::c::declare $id
    }

    proc file_set { id } {
        close_dataset $id "file:close"
    }

    proc filename { id } {
        debug "filename($id)"
        set s [ adlb::retrieve $id ]
        set i [ string first : $s ]
        set i [ expr $i + 1 ]
        set result [ string range $s $i end ]
        return $result
    }

    proc close_dataset { id value } {
        global WORK_TYPE
        adlb::store $id $value
        set ranks [ adlb::close $id ]
        foreach rank $ranks {
            puts "notify: $rank"
            adlb::put $rank $WORK_TYPE(CONTROL) "close $id"
        }
    }
}

Rename file_get{} to filename{} and fix
Rename file_get{} to filename{} and fix


git-svn-id: f1d3e1ea5383cd3c118991be0c13c0bc6713118f@815 dc4e9af1-7f46-4ead-bba6-71afc04862de
