.packageName <- "Ruuid"
#Copyright R. Gentleman, 2003, All rights reserved

## Ensure that the methods package is available
.onLoad <- function(lib, pkg) {
    require("methods", character=TRUE, quietly=TRUE)

    if((.Platform$OS.type == "windows")
       && ("Biobase" %in% installed.packages()[,"Package"])
       && (interactive()) && (.Platform$GUI ==  "Rgui")){
        if (require("Biobase"))
          addVigs2WinMenu("Ruuid")
    }
}

## uuidt
setClass("uuidt", representation(uuid="character"))

if (is.null(getGeneric("uuid")))
    setGeneric("uuid", function(object)
               standardGeneric("uuid"))
setMethod("uuid", "uuidt", function(object)
          object@uuid)

setMethod("show", "uuidt", function(object) {
    z <- .Call("Ruuid_printuuid", object, PACKAGE="Ruuid")
    print(z)
})

## Ruuid
setClass("Ruuid", representation(stringRep="character", uuid="uuidt"))

setMethod("uuid", "Ruuid", function(object) object@uuid)

setMethod("show", "Ruuid", function(object) print(object@stringRep))

setMethod("as.character", "Ruuid", function(x) x@stringRep)

setMethod("==", signature("Ruuid", "Ruuid"),
          function(e1, e2) as.character(e1) == as.character(e2))

setMethod("!=", signature("Ruuid", "Ruuid"),
          function(e1, e2) as.character(e1) != as.character(e2))



getuuid <- function(cur)
{
    if (missing(cur))
        x <- .Call("Ruuid_getuuid", PACKAGE="Ruuid")
    else if (is(cur,"uuidt")) {
        y <- .Call("Ruuid_uuid2str", cur, PACKAGE="Ruuid")
        x <- new("Ruuid",stringRep=y, uuid=cur)
    }
    else if (is.character(cur)) {
        y <- .Call("Ruuid_str2uuid", cur, PACKAGE="Ruuid")
        x <- new("Ruuid",stringRep=cur,uuid=y)
    }
    else {
        stop("Incorrect parameter type")
    }
    x
}


