#ifndef _NSRRECOG_ // -*-c++-*-
#define _NSRRECOG_
//----------------------------------------------------------------------
//  nsrRecog.h
//
//   This file defines the structures for part 2 of the ISO/IE13346
//   standard, which specifies Volume and Boot Recognition.
//
//      Unpublished Confidential Information of Hewlett-Packard
//      Company. Do not disclose.  Copyright (c) Hewlett-Packard
//      Company 1995. All rights reserved
// 
// The contents of this software are proprietary and confidential to
// the Hewlett- Packard Company, and are limited in distribution to
// those with a direct need to know.  Individuals having access to
// this software are responsible for maintaining the confidentiality
// of the content and for keeping the software secure when not in use.
// Transfer to any party is strictly forbidden other than as expressly
// permitted in writing by Hewlett-Packard Company.  Unauthorized
// transfer to or possession by any unauthorized party may be a
// criminal offense.
//
//                  RESTRICTED RIGHTS LEGEND
//
//      Use,  duplication,  or disclosure by the U. S. Government is
//      subject to restrictions as set forth in subparagraph (c) (1)
//      (ii) in the Rights in Technical Data and Computer Software
//      clause in DFARS 252.227-7013 or any other successor clause.
//
//                      HEWLETT-PACKARD COMPANY
//                      3000 Hanover St.
//                      Palo Alto, CA  94304 U.S.A.
//
//      Rights for non-DOD U.S. Government Departments and Agencies
//      are as set forth in FAR 52.227-19 (c) (1,2) or any other
//      successor clause.
//
//  CLASSES:
//   VolStructDesc
//   BegExtAreaDesc
//   NSRDescriptor
//   TermExtAreaDesc
//  
//  NOTES:
//   These are VERY SIMPLE descriptors, not used for much by HP.
//
//----------------------------------------------------------------------
// $Source: /projects/HMS/nsr/udfCore/descr/nsrRecog.h,v $
// $Revision: 1.8 $     $Author: hmgr $
// $State: Exp $        $Locker:  $
// $Date: 96/01/15 11:13:07 $


// Class: VolStructDesc
//
// This is the basis for all the descriptors in this portion of the
// standard, and the other descriptors are derived from it. Note that
// no error is contained inside of it, as it is not tagged. The basic
// operations it supports are construction, access to its (four)
// fields, and to/fromISO().

// METHOD: VolStructDesc::structType()
// METHOD: VolStructDesc::standardId()
// METHOD: VolStructDesc::structVersion()
// METHOD: VolStructDesc::structData()
//
// These methods allow access to the fields inside this descriptor.
// The first three are set/get methods, depending on the presence or
// absence of an argument. The structData() method returns a BYTE
// pointer which may be used for both setting and getting its field
// inside the descriptor.

// METHOD VolStructDesc::toISO()
// METHOD VolStructDesc::fromISO()
//
// These two methods provide the standard support for descriptors,
// except that since they are not tagged, there is no concept of an
// error, and there is no requirement for a location to be encoded
// inside them.

class VolStructDesc {

protected:

    Error err;

    Uint8     structureType      ;
    Bytes     standardIdentifier ;
    Uint8     structureVersion   ;
    ZeroBytes structureData      ;

public:
    
    VolStructDesc() :

        err                ( error_None ),
        structureType      ( 0 ),
        standardIdentifier ( 1, 5 ),
        structureVersion   ( 6 ),
        structureData      ( 7, 2041) {
    }

    virtual ~VolStructDesc() {}

    Error error() const { return err; }

    UINT32 descLen()         const { return (2048); }

    UINT8 structType()       const { return structureType; }
    void structType(UINT8 type)    { structureType = type; }

    String standardId()      const { return standardIdentifier; }
    void standardId(String id)     { standardIdentifier = id  ; }

    UINT8 structVersion()   const  { return structureVersion; }
    void structVersion(UINT8 vers) { structureVersion = vers; }

    void toISO( BYTE_PTR rbp ) {

        structureType      .toISO( rbp );
        standardIdentifier .toISO( rbp );
        structureVersion   .toISO( rbp );
        bodyToISO                ( rbp );
    }
    
    void fromISO( CONST_BYTE_PTR rbp ) {

        structureType      .fromISO( rbp );
        standardIdentifier .fromISO( rbp );
        structureVersion   .fromISO( rbp );
        bodyFromISO                ( rbp );
    }

protected:

    void bodyToISO( BYTE_PTR rbp ) {}
    void bodyFromISO( CONST_BYTE_PTR rbp ) {}
    
};

// Class: BegExtAreaDesc
// Class: NSRDescriptor
// Class: TermExtAreaDesc
//
// These are simple VolStructDesc derivatives, which set the fields as
// appropriate when constructed, use the inherited to/fromISO()
// methods.

class BegExtAreaDesc : public VolStructDesc {

    ZeroBytes sd;

public:
    
    BegExtAreaDesc() :

        sd( structureData.field.start(),structureData.field.len() ) {

        structType    ( 0 );
        standardId    ( "BEA01" );
        structVersion ( 1 );
        
    }

     void bodyToISO( BYTE_PTR rbp ) {
        sd .toISO( rbp );
     }

     void bodyFromISO( CONST_BYTE_PTR rbp ) {
        sd .fromISO( rbp );
     }

};

class NSRDescriptor : public VolStructDesc {

    ZeroBytes sd;

public:
    
    NSRDescriptor() :

        sd ( structureData.field.start(),structureData.field.len() ) {

        structType    ( 0 );
        standardId    ( "NSR02" );
        structVersion ( 1 );
        
    }

protected:

     void bodyToISO( BYTE_PTR rbp ) {
        sd .toISO( rbp );
     }

     void bodyFromISO( CONST_BYTE_PTR rbp ) {
        sd .fromISO( rbp );
     }

};

class TermExtAreaDesc : public VolStructDesc {

    ZeroBytes sd;

public:
    
    TermExtAreaDesc() :
        
        sd ( structureData.field.start(),structureData.field.len() ) {

        structType    ( 0 );
        standardId    ( "TEA01" );
        structVersion ( 1 );
        
    }

protected:

     void bodyToISO( BYTE_PTR rbp ) {
        sd .toISO( rbp );
     }

     void bodyFromISO( CONST_BYTE_PTR rbp ) {
        sd .fromISO( rbp );
     }

};

// Class BootDescFlags
//
// This defines the bits inside the flags field in the boot
// descriptor. For now, it only supports to/fromISO(), and gives
// access to the bits inside via public data members.
//
// class BootDescFlags {
//
// public:
//     FieldInfo field;
// private:
//
// public:
//    
//     Bit16  erase    ;
//     Bits16 reserved ;
// 
//     BootDescFlags(UINT16 o) :
//         Field(o,2),
//         erase    ( 0 ),
//         reserved ( 1, 15 ) {
//         reserved = 0;
//     }
//     void clear() {
//         erase    .clear();
//         reserved .clear();
//     }
// 
//     void toISO(BYTE_PTR rbp) {
//         rbp += fieldStart();
//         erase    .toISO(rbp);
//         reserved .toISO(rbp);
//     }
//     void fromISO( CONST_BYTE_PTR rbp ) {
//         rbp += fieldStart();
//         erase    .fromISO(rbp);
//         reserved .fromISO(rbp);
//     }
// };

// Class: BootDesc
//
// This is the Boot descriptor, derived from the VolStructDesc. It is
// not implemented in toto, since we do not use it. It is missing some
// big pieces.

// class BootDesc : public VolStructDesc {
// 
//     Uint8         reserved           ;
//     RegID         architectureType   ;
//     RegID         bootIdentifier     ;
//     Uint32        bootExtentLocation ;
//     Uint32        bootExtentLength   ;
//     Uint64        loadAddress        ;
//     Uint64        startAddress       ;
//     TimeStamp     descCreationDate   ;
//     BootDescFlags flags              ;
//     ZeroBytes     reservedBytes      ;
//     ZeroBytes     bootUse            ;
//     
// public:
//     
//     BootDesc() :
// 
//         reserved           (   7 ),
//         architectureType   (   8 ),
//         bootIdentifier     (  40 ),
//         bootExtentLocation (  72 ),
//         bootExtentLength   (  76 ),
//         loadAddress        (  80 ),
//         startAddress       (  88 ),
//         descCreationDate   (  96 ),
//         flags              ( 108 ),
//         reservedBytes      ( 110, 32 ),
//         bootUse            ( 142, 1906) {
// 
//      structType    ( 0 );
//      standardId    ( "BOOT2" );
//      structVersion ( 1 );
// 
//         reserved      = 0;
//
//        // The following initialization should be replaced with
//        // the appropriate initialization of the unique fields for
//        // this descriptor. For now, they are ALL set to zero.
//
//     }
// 
// protected:
// 
//      void bodyToISO( BYTE_PTR rbp ) {
// 
//          reserved           .toISO( rbp );
//          architectureType   .toISO( rbp );
//          bootIdentifier     .toISO( rbp );
//          bootExtentLocation .toISO( rbp );
//          bootExtentLength   .toISO( rbp );
//          loadAddress        .toISO( rbp );
//          startAddress       .toISO( rbp );
//          descCreationDate   .toISO( rbp );
//          flags              .toISO( rbp );
//          reservedBytes      .toISO( rbp );
//          bootUse            .toISO( rbp );
// 
//      }
// 
//      void bodyFromISO( CONST_BYTE_PTR rbp ) {
// 
//          reserved           .fromISO( rbp );
//          architectureType   .fromISO( rbp );
//          bootIdentifier     .fromISO( rbp );
//          bootExtentLocation .fromISO( rbp );
//          bootExtentLength   .fromISO( rbp );
//          loadAddress        .fromISO( rbp );
//          startAddress       .fromISO( rbp );
//          descCreationDate   .fromISO( rbp );
//          flags              .fromISO( rbp );
//          reservedBytes      .fromISO( rbp );
//          bootUse            .fromISO( rbp );
// 
//      }
//
// };

#endif





