/*
* This file is part of rasdaman community.
*
* Rasdaman community is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Rasdaman community is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with rasdaman community. If not, see .
*
* Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009 Peter Baumann /
rasdaman GmbH.
*
* For more information please see
* or contact Peter Baumann via .
*/
static const char rcsid[] = "@(#)raslib, r_Primitive_Type: $Header: /home/rasdev/CVS-repository/rasdaman/raslib/primitivetype.cc,v 1.26 2003/12/27 23:01:21 rasdev Exp $";
#include "raslib/primitivetype.hh"
#include "raslib/rminit.hh"
#include "raslib/rmdebug.hh"
#include "raslib/odmgtypes.hh"
#include "raslib/endian.hh"
#include "raslib/error.hh"
#include
#include
#include
r_Primitive_Type::r_Primitive_Type()
: r_Base_Type(),
typeId(UNKNOWNTYPE)
{
}
r_Primitive_Type::r_Primitive_Type( const char* newTypeName,
const r_Type::r_Type_Id newTypeId )
: r_Base_Type(newTypeName, 0),
typeId(newTypeId)
{
switch( typeId )
{
case ULONG: typeSize = 4; break;
case USHORT: typeSize = 2; break;
case BOOL: typeSize = 1; break;
case LONG: typeSize = 4; break;
case SHORT: typeSize = 2; break;
case OCTET: typeSize = 1; break;
case DOUBLE: typeSize = 8; break;
case FLOAT: typeSize = 4; break;
case CHAR: typeSize = 1; break;
case COMPLEXTYPE1:
typeSize = 2 * sizeof(float);
break;
case COMPLEXTYPE2:
typeSize = 2 * sizeof(double);
break;
default:
RMDBGONCE(3, RMDebug::module_raslib, "r_Primitive_Type", "r_Primitive_Type(....) bad typeId " << typeId);
break;
}
}
r_Primitive_Type::r_Primitive_Type( const r_Primitive_Type& oldObj )
: r_Base_Type(oldObj),
typeId(oldObj.typeId)
{
}
const r_Primitive_Type&
r_Primitive_Type::operator=( const r_Primitive_Type& oldObj )
{
// Gracefully handle self assignment
if (this == &oldObj) return *this;
r_Base_Type::operator=( oldObj );
typeId = oldObj.typeId;
return *this;
}
r_Primitive_Type::~r_Primitive_Type()
{
}
r_Type*
r_Primitive_Type::clone() const
{
return new r_Primitive_Type( *this );
}
r_Type::r_Type_Id
r_Primitive_Type::type_id() const
{
return typeId;
}
bool
r_Primitive_Type::isPrimitiveType() const
{
return true;
}
void
r_Primitive_Type::convertToLittleEndian(char* cells, r_Bytes noCells) const
{
char c0 = 0;
char c1 = 0;
char c2 = 0;
char c3 = 0;
r_Bytes i = 0;
switch( typeId )
{
case USHORT:
case SHORT:
for(i=0; i