libs-base/Headers/Foundation/NSUnit.h

421 lines
9.4 KiB
C
Raw Normal View History

2019-09-30 19:59:50 +00:00
/* Definition of class NSUnit
Copyright (C) 2019 Free Software Foundation, Inc.
By: Gregory John Casamento <greg.casamento@gmail.com>
2019-09-30 19:59:50 +00:00
Date: Mon Sep 30 15:58:21 EDT 2019
This file is part of the GNUstep Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
2019-09-30 19:59:50 +00:00
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free
Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110 USA.
2019-09-30 19:59:50 +00:00
*/
#ifndef _NSUnit_h_GNUSTEP_BASE_INCLUDE
#define _NSUnit_h_GNUSTEP_BASE_INCLUDE
#import <Foundation/NSObject.h>
#if OS_API_VERSION(MAC_OS_X_VERSION_10_12, GS_API_LATEST)
2019-09-30 19:59:50 +00:00
#if defined(__cplusplus)
extern "C" {
#endif
2019-10-02 09:08:37 +00:00
// Unit converter
@interface NSUnitConverter : NSObject
2019-10-24 22:16:59 +00:00
- (double) baseUnitValueFromValue: (double)value;
- (double) valueFromBaseUnitValue: (double)baseUnitValue;
@end
2019-10-02 09:08:37 +00:00
// Linea converter... for things like C <-> F conversion...
2019-10-02 06:05:18 +00:00
@interface NSUnitConverterLinear : NSUnitConverter <NSCoding>
{
double _coefficient;
double _constant;
}
- (instancetype) initWithCoefficient: (double)coefficient;
- (instancetype) initWithCoefficient: (double)coefficient
constant: (double)constant;
- (double) coefficient;
- (double) constant;
@end
2019-10-02 09:08:37 +00:00
// Units... abstract...
@interface NSUnit : NSObject <NSCopying, NSCoding>
{
NSString *_symbol;
}
2019-10-24 22:16:59 +00:00
- (instancetype) init;
- (instancetype) initWithSymbol: (NSString *)symbol;
2019-10-02 11:09:32 +00:00
- (NSString *) symbol;
2019-09-30 19:59:50 +00:00
@end
2019-10-02 09:08:37 +00:00
// Dimension using units....
@interface NSDimension : NSUnit <NSCoding>
{
2019-10-06 03:09:12 +00:00
double _value;
2019-10-02 09:08:37 +00:00
NSUnitConverter *_converter;
}
- (NSUnitConverter *) converter;
- (instancetype) initWithSymbol: (NSString *)symbol converter: (NSUnitConverter *)converter;
2019-10-02 09:08:37 +00:00
+ (instancetype) baseUnit;
@end
2019-10-02 09:47:03 +00:00
// Predefined....
2019-10-24 22:15:37 +00:00
@interface NSUnitAcceleration : NSDimension
2019-10-02 09:47:03 +00:00
/*
Base unit - metersPerSecondSquared
*/
2019-10-06 15:48:21 +00:00
+ (NSUnitAcceleration *) metersPerSecondSquared;
+ (NSUnitAcceleration *) gravity;
2019-10-02 09:47:03 +00:00
@end
2019-10-24 22:15:37 +00:00
@interface NSUnitAngle : NSDimension
2019-10-02 09:47:03 +00:00
/*
Base unit - degrees
*/
2019-10-06 15:48:21 +00:00
+ (NSUnitAngle *) degrees;
+ (NSUnitAngle *) arcMinutes;
+ (NSUnitAngle *) arcSeconds;
+ (NSUnitAngle *) radians;
+ (NSUnitAngle *) gradians;
+ (NSUnitAngle *) revolutions;
2019-10-02 09:47:03 +00:00
@end
2019-10-24 22:15:37 +00:00
@interface NSUnitArea : NSDimension
2019-10-02 09:47:03 +00:00
/*
Base unit - squareMeters
*/
2019-10-06 15:48:21 +00:00
+ (NSUnitArea *) squareMegameters;
+ (NSUnitArea *) squareKilometers;
+ (NSUnitArea *) squareMeters;
+ (NSUnitArea *) squareCentimeters;
+ (NSUnitArea *) squareMillimeters;
+ (NSUnitArea *) squareMicrometers;
+ (NSUnitArea *) squareNanometers;
+ (NSUnitArea *) squareInches;
+ (NSUnitArea *) squareFeet;
+ (NSUnitArea *) squareYards;
+ (NSUnitArea *) squareMiles;
+ (NSUnitArea *) acres;
+ (NSUnitArea *) ares;
+ (NSUnitArea *) hectares;
2019-10-02 09:47:03 +00:00
@end
2019-10-24 22:15:37 +00:00
@interface NSUnitConcentrationMass : NSDimension
2019-10-02 09:47:03 +00:00
/*
Base unit - gramsPerLiter
*/
2019-10-06 15:48:21 +00:00
+ (NSUnitConcentrationMass *) gramsPerLiter;
+ (NSUnitConcentrationMass *) milligramsPerDeciliter;
2019-10-02 09:47:03 +00:00
2019-10-24 22:17:59 +00:00
+ (NSUnitConcentrationMass *) millimolesPerLiterWithGramsPerMole: (double)gramsPerMole;
2019-10-02 09:47:03 +00:00
@end
2019-10-24 22:15:37 +00:00
@interface NSUnitDispersion : NSDimension
2019-10-02 09:47:03 +00:00
/*
Base unit - partsPerMillion
*/
2019-10-06 15:48:21 +00:00
+ (NSUnitDispersion *) partsPerMillion;
2019-10-02 09:47:03 +00:00
@end
2019-10-24 22:15:37 +00:00
@interface NSUnitDuration : NSDimension
2019-10-02 09:47:03 +00:00
/*
Base unit - seconds
*/
2019-10-06 15:48:21 +00:00
+ (NSUnitDuration *) seconds;
+ (NSUnitDuration *) minutes;
+ (NSUnitDuration *) hours;
2019-10-02 09:47:03 +00:00
@end
2019-10-24 22:15:37 +00:00
@interface NSUnitElectricCharge : NSDimension
2019-10-02 09:47:03 +00:00
/*
Base unit - coulombs
*/
2019-10-06 15:48:21 +00:00
+ (NSUnitElectricCharge *) coulombs;
+ (NSUnitElectricCharge *) megaampereHours;
+ (NSUnitElectricCharge *) kiloampereHours;
+ (NSUnitElectricCharge *) ampereHours;
+ (NSUnitElectricCharge *) milliampereHours;
+ (NSUnitElectricCharge *) microampereHours;
2019-10-02 09:47:03 +00:00
@end
2019-10-24 22:15:37 +00:00
@interface NSUnitElectricCurrent : NSDimension
2019-10-02 09:47:03 +00:00
/*
Base unit - amperes
*/
2019-10-06 15:48:21 +00:00
+ (NSUnitElectricCurrent *) megaamperes;
+ (NSUnitElectricCurrent *) kiloamperes;
+ (NSUnitElectricCurrent *) amperes;
+ (NSUnitElectricCurrent *) milliamperes;
+ (NSUnitElectricCurrent *) microamperes;
2019-10-02 09:47:03 +00:00
@end
2019-10-24 22:15:37 +00:00
@interface NSUnitElectricPotentialDifference : NSDimension
2019-10-02 09:47:03 +00:00
/*
Base unit - volts
*/
2019-10-06 15:48:21 +00:00
+ (NSUnitElectricPotentialDifference *) megavolts;
+ (NSUnitElectricPotentialDifference *) kilovolts;
+ (NSUnitElectricPotentialDifference *) volts;
+ (NSUnitElectricPotentialDifference *) millivolts;
+ (NSUnitElectricPotentialDifference *) microvolts;
2019-10-02 09:47:03 +00:00
@end
2019-10-24 22:15:37 +00:00
@interface NSUnitElectricResistance : NSDimension
2019-10-02 09:47:03 +00:00
/*
Base unit - ohms
*/
2019-10-06 15:48:21 +00:00
+ (NSUnitElectricResistance *) megaohms;
+ (NSUnitElectricResistance *) kiloohms;
+ (NSUnitElectricResistance *) ohms;
+ (NSUnitElectricResistance *) milliohms;
+ (NSUnitElectricResistance *) microohms;
2019-10-02 09:47:03 +00:00
@end
2019-10-24 22:15:37 +00:00
@interface NSUnitEnergy : NSDimension
2019-10-02 09:47:03 +00:00
/*
Base unit - joules
*/
2019-10-06 15:48:21 +00:00
+ (NSUnitEnergy *) kilojoules;
+ (NSUnitEnergy *) joules;
+ (NSUnitEnergy *) kilocalories;
+ (NSUnitEnergy *) calories;
+ (NSUnitEnergy *) kilowattHours;
2019-10-02 09:47:03 +00:00
@end
2019-10-24 22:15:37 +00:00
@interface NSUnitFrequency : NSDimension
2019-10-02 09:47:03 +00:00
/*
Base unit - hertz
*/
2019-10-06 15:48:21 +00:00
+ (NSUnitFrequency *) terahertz;
+ (NSUnitFrequency *) gigahertz;
+ (NSUnitFrequency *) megahertz;
+ (NSUnitFrequency *) kilohertz;
+ (NSUnitFrequency *) hertz;
+ (NSUnitFrequency *) millihertz;
+ (NSUnitFrequency *) microhertz;
+ (NSUnitFrequency *) nanohertz;
2019-10-02 09:47:03 +00:00
@end
2019-10-24 22:15:37 +00:00
@interface NSUnitFuelEfficiency : NSDimension
2019-10-02 09:47:03 +00:00
/*
Base unit - litersPer100Kilometers
*/
2019-10-06 15:48:21 +00:00
+ (NSUnitFuelEfficiency *) litersPer100Kilometers;
+ (NSUnitFuelEfficiency *) milesPerImperialGallon;
+ (NSUnitFuelEfficiency *) milesPerGallon;
2019-10-02 09:47:03 +00:00
@end
2019-10-24 22:15:37 +00:00
@interface NSUnitLength : NSDimension
2019-10-02 09:47:03 +00:00
/*
Base unit - meters
*/
2019-10-06 15:48:21 +00:00
+ (NSUnitLength *) megameters;
+ (NSUnitLength *) kilometers;
+ (NSUnitLength *) hectometers;
+ (NSUnitLength *) decameters;
+ (NSUnitLength *) meters;
+ (NSUnitLength *) decimeters;
+ (NSUnitLength *) centimeters;
+ (NSUnitLength *) millimeters;
+ (NSUnitLength *) micrometers;
+ (NSUnitLength *) nanometers;
+ (NSUnitLength *) picometers;
+ (NSUnitLength *) inches;
+ (NSUnitLength *) feet;
+ (NSUnitLength *) yards;
+ (NSUnitLength *) miles;
+ (NSUnitLength *) scandinavianMiles;
+ (NSUnitLength *) lightyears;
+ (NSUnitLength *) nauticalMiles;
+ (NSUnitLength *) fathoms;
+ (NSUnitLength *) furlongs;
+ (NSUnitLength *) astronomicalUnits;
+ (NSUnitLength *) parsecs;
2019-10-02 09:47:03 +00:00
@end
2019-10-24 22:15:37 +00:00
@interface NSUnitIlluminance : NSDimension
2019-10-02 09:47:03 +00:00
/*
Base unit - lux
*/
2019-10-06 15:48:21 +00:00
+ (NSUnitIlluminance *) lux;
2019-10-02 09:47:03 +00:00
@end
2019-10-24 22:15:37 +00:00
@interface NSUnitMass : NSDimension
2019-10-02 09:47:03 +00:00
/*
Base unit - kilograms
*/
2019-10-06 15:48:21 +00:00
+ (NSUnitMass *) kilograms;
+ (NSUnitMass *) grams;
+ (NSUnitMass *) decigrams;
+ (NSUnitMass *) centigrams;
+ (NSUnitMass *) milligrams;
+ (NSUnitMass *) micrograms;
+ (NSUnitMass *) nanograms;
+ (NSUnitMass *) picograms;
+ (NSUnitMass *) ounces;
2019-10-24 21:06:06 +00:00
+ (NSUnitMass *) pounds;
2019-10-06 15:48:21 +00:00
+ (NSUnitMass *) stones;
+ (NSUnitMass *) metricTons;
+ (NSUnitMass *) shortTons;
+ (NSUnitMass *) carats;
+ (NSUnitMass *) ouncesTroy;
+ (NSUnitMass *) slugs;
2019-10-02 09:47:03 +00:00
@end
2019-10-24 22:15:37 +00:00
@interface NSUnitPower : NSDimension
2019-10-02 09:47:03 +00:00
/*
Base unit - watts
*/
2019-10-06 15:48:21 +00:00
+ (NSUnitPower *) terawatts;
+ (NSUnitPower *) gigawatts;
+ (NSUnitPower *) megawatts;
+ (NSUnitPower *) kilowatts;
+ (NSUnitPower *) watts;
+ (NSUnitPower *) milliwatts;
+ (NSUnitPower *) microwatts;
+ (NSUnitPower *) nanowatts;
+ (NSUnitPower *) picowatts;
+ (NSUnitPower *) femtowatts;
+ (NSUnitPower *) horsepower;
2019-10-02 09:47:03 +00:00
@end
2019-10-24 22:15:37 +00:00
@interface NSUnitPressure : NSDimension
2019-10-02 09:47:03 +00:00
/*
Base unit - newtonsPerMetersSquared (equivalent to 1 pascal)
*/
2019-10-06 15:48:21 +00:00
+ (NSUnitPressure *) newtonsPerMetersSquared;
+ (NSUnitPressure *) gigapascals;
+ (NSUnitPressure *) megapascals;
+ (NSUnitPressure *) kilopascals;
+ (NSUnitPressure *) hectopascals;
+ (NSUnitPressure *) inchesOfMercury;
+ (NSUnitPressure *) bars;
+ (NSUnitPressure *) millibars;
+ (NSUnitPressure *) millimetersOfMercury;
+ (NSUnitPressure *) poundsForcePerSquareInch;
2019-10-02 09:47:03 +00:00
@end
2019-10-24 22:15:37 +00:00
@interface NSUnitSpeed : NSDimension
2019-10-02 09:47:03 +00:00
/*
Base unit - metersPerSecond
*/
2019-10-06 15:48:21 +00:00
+ (NSUnitSpeed *) metersPerSecond;
+ (NSUnitSpeed *) kilometersPerHour;
+ (NSUnitSpeed *) milesPerHour;
+ (NSUnitSpeed *) knots;
2019-10-02 09:47:03 +00:00
@end
2019-10-24 22:15:37 +00:00
@interface NSUnitTemperature : NSDimension
2019-10-02 09:47:03 +00:00
/*
Base unit - kelvin
*/
2019-10-06 15:48:21 +00:00
+ (NSUnitTemperature *) kelvin;
+ (NSUnitTemperature *) celsius;
+ (NSUnitTemperature *) fahrenheit;
2019-10-02 09:47:03 +00:00
@end
2019-10-24 22:15:37 +00:00
@interface NSUnitVolume : NSDimension
2019-10-02 09:47:03 +00:00
/*
Base unit - liters
*/
2019-10-06 15:48:21 +00:00
+ (NSUnitVolume *) megaliters;
+ (NSUnitVolume *) kiloliters;
+ (NSUnitVolume *) liters;
+ (NSUnitVolume *) deciliters;
+ (NSUnitVolume *) centiliters;
+ (NSUnitVolume *) milliliters;
+ (NSUnitVolume *) cubicKilometers;
+ (NSUnitVolume *) cubicMeters;
+ (NSUnitVolume *) cubicDecimeters;
+ (NSUnitVolume *) cubicCentimeters;
+ (NSUnitVolume *) cubicMillimeters;
+ (NSUnitVolume *) cubicInches;
+ (NSUnitVolume *) cubicFeet;
+ (NSUnitVolume *) cubicYards;
+ (NSUnitVolume *) cubicMiles;
+ (NSUnitVolume *) acreFeet;
+ (NSUnitVolume *) bushels;
+ (NSUnitVolume *) teaspoons;
+ (NSUnitVolume *) tablespoons;
+ (NSUnitVolume *) fluidOunces;
+ (NSUnitVolume *) cups;
+ (NSUnitVolume *) pints;
+ (NSUnitVolume *) quarts;
+ (NSUnitVolume *) gallons;
+ (NSUnitVolume *) imperialTeaspoons;
+ (NSUnitVolume *) imperialTablespoons;
+ (NSUnitVolume *) imperialFluidOunces;
+ (NSUnitVolume *) imperialPints;
+ (NSUnitVolume *) imperialQuarts;
+ (NSUnitVolume *) imperialGallons;
+ (NSUnitVolume *) metricCups;
2019-10-02 09:47:03 +00:00
@end
2019-09-30 19:59:50 +00:00
#if defined(__cplusplus)
}
#endif
#endif /* GS_API_MACOSX */
#endif /* _NSUnit_h_GNUSTEP_BASE_INCLUDE */