Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

RunArrays.h

Go to the documentation of this file.
00001 /*
00002  **********************************************************************
00003  *   Copyright (C) 2003, International Business Machines
00004  *   Corporation and others.  All Rights Reserved.
00005  **********************************************************************
00006  */
00007 
00008 #ifndef __RUNARRAYS_H
00009 
00010 #define __RUNARRAYS_H
00011 
00012 #include "layout/LETypes.h"
00013 #include "layout/LEFontInstance.h"
00014 
00015 #include "unicode/utypes.h"
00016 #include "unicode/locid.h"
00017 
00018 U_NAMESPACE_BEGIN
00019 
00025 #define INITIAL_CAPACITY 16
00026 
00033 #define CAPACITY_GROW_LIMIT 128
00034 
00043 class U_LAYOUTEX_API RunArray : public UObject
00044 {
00045 public:
00056     RunArray(const le_int32 *limits, le_int32 count);
00057 
00069     RunArray(le_int32 initalCapacity);
00070 
00076     virtual ~RunArray();
00077 
00085     le_int32 getCount() const;
00086 
00095     le_int32 getLimit() const;
00096 
00106     le_int32 getLimit(le_int32 run) const;
00107 
00132     le_int32 add(le_int32 limit);
00133 
00139     virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00140 
00146     static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00147 
00148 protected:
00161     virtual void init(le_int32 capacity);
00162 
00175     virtual void grow(le_int32 capacity);
00176 
00186     le_bool fClientArrays;
00187 
00188 private:
00193     static const char fgClassID;
00194 
00195     le_int32 ensureCapacity();
00196 
00197         RunArray();
00198         RunArray(const RunArray & /*other*/);
00199         RunArray &operator=(const RunArray & /*other*/) { return *this; };
00200 
00201     const le_int32 *fLimits;
00202           le_int32  fCount;
00203           le_int32  fCapacity;
00204 };
00205 
00206 inline RunArray::RunArray()
00207         : UObject(), fClientArrays(false), fLimits(NULL), fCount(0), fCapacity(0)
00208 {
00209         // nothing else to do...
00210 }
00211 
00212 inline RunArray::RunArray(const RunArray & /*other*/)
00213         : UObject(), fClientArrays(false), fLimits(NULL), fCount(0), fCapacity(0)
00214 {
00215         // nothing else to do...
00216 }
00217 
00218 inline RunArray::RunArray(const le_int32 *limits, le_int32 count)
00219     : UObject(), fClientArrays(true), fLimits(limits), fCount(count), fCapacity(count)
00220 {
00221     // nothing else to do...
00222 }
00223 
00224 inline RunArray::RunArray(le_int32 initialCapacity)
00225     : fClientArrays(false), fLimits(NULL), fCount(0), fCapacity(initialCapacity)
00226 {
00227     if (initialCapacity > 0) {
00228         fLimits = LE_NEW_ARRAY(le_int32, fCapacity);
00229     }
00230 }
00231 
00232 inline RunArray::~RunArray()
00233 {
00234     if (! fClientArrays) {
00235         LE_DELETE_ARRAY(fLimits);
00236         fLimits = NULL;
00237     }
00238 }
00239 
00240 inline le_int32 RunArray::getCount() const
00241 {
00242     return fCount;
00243 }
00244 
00245 inline le_int32 RunArray::getLimit(le_int32 run) const
00246 {
00247     if (run < 0 || run >= fCount) {
00248         return -1;
00249     }
00250 
00251     return fLimits[run];
00252 }
00253 
00254 inline le_int32 RunArray::getLimit() const
00255 {
00256     return getLimit(fCount - 1);
00257 }
00258 
00265 class U_LAYOUTEX_API FontRuns : public RunArray
00266 {
00267 public:
00280     FontRuns(const LEFontInstance **fonts, const le_int32 *limits, le_int32 count);
00281 
00293     FontRuns(le_int32 initialCapacity);
00294 
00300     virtual ~FontRuns();
00301 
00315     const LEFontInstance *getFont(le_int32 run) const;
00316 
00317 
00339     le_int32 add(const LEFontInstance *font, le_int32 limit);
00340 
00346     virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00347 
00353     static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00354 
00355 protected:
00356     virtual void init(le_int32 capacity);
00357     virtual void grow(le_int32 capacity);
00358 
00359 private:
00360 
00361         FontRuns();
00362         FontRuns(const FontRuns &other);
00363         FontRuns &operator=(const FontRuns & /*other*/) { return *this; };
00364 
00369     static const char fgClassID;
00370 
00371     const LEFontInstance **fFonts;
00372 };
00373 
00374 inline FontRuns::FontRuns()
00375         : RunArray(0), fFonts(NULL)
00376 {
00377         // nothing else to do...
00378 }
00379 
00380 inline FontRuns::FontRuns(const FontRuns & /*other*/)
00381         : RunArray(0), fFonts(NULL)
00382 {
00383         // nothing else to do...
00384 }
00385 
00386 inline FontRuns::FontRuns(const LEFontInstance **fonts, const le_int32 *limits, le_int32 count)
00387     : RunArray(limits, count), fFonts(fonts)
00388 {
00389     // nothing else to do...
00390 }
00391 
00392 inline FontRuns::FontRuns(le_int32 initialCapacity)
00393     : RunArray(initialCapacity), fFonts(NULL)
00394 {
00395     if (initialCapacity > 0) {
00396         fFonts = LE_NEW_ARRAY(const LEFontInstance *, initialCapacity);
00397     }
00398 }
00399 
00400 inline FontRuns::~FontRuns()
00401 {
00402     if (! fClientArrays) {
00403         LE_DELETE_ARRAY(fFonts);
00404         fFonts = NULL;
00405     }
00406 }
00407 
00414 class U_LAYOUTEX_API LocaleRuns : public RunArray
00415 {
00416 public:
00429     LocaleRuns(const Locale **locales, const le_int32 *limits, le_int32 count);
00430 
00442     LocaleRuns(le_int32 initialCapacity);
00443 
00449     virtual ~LocaleRuns();
00450 
00464     const Locale *getLocale(le_int32 run) const;
00465 
00466 
00488     le_int32 add(const Locale *locale, le_int32 limit);
00489 
00495     virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00496 
00502     static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00503 
00504 protected:
00505     virtual void init(le_int32 capacity);
00506     virtual void grow(le_int32 capacity);
00507 
00508 private:
00509 
00510         LocaleRuns();
00511         LocaleRuns(const LocaleRuns &other);
00512         LocaleRuns &operator=(const LocaleRuns & /*other*/) { return *this; };
00513 
00518     static const char fgClassID;
00519 
00520     const Locale **fLocales;
00521 };
00522 
00523 inline LocaleRuns::LocaleRuns()
00524         : RunArray(0), fLocales(NULL)
00525 {
00526         // nothing else to do...
00527 }
00528 
00529 inline LocaleRuns::LocaleRuns(const LocaleRuns & /*other*/)
00530         : RunArray(0), fLocales(NULL)
00531 {
00532         // nothing else to do...
00533 }
00534 
00535 inline LocaleRuns::LocaleRuns(const Locale **locales, const le_int32 *limits, le_int32 count)
00536     : RunArray(limits, count), fLocales(locales)
00537 {
00538     // nothing else to do...
00539 }
00540 
00541 inline LocaleRuns::LocaleRuns(le_int32 initialCapacity)
00542     : RunArray(initialCapacity), fLocales(NULL)
00543 {
00544     if (initialCapacity > 0) {
00545         fLocales = LE_NEW_ARRAY(const Locale *, initialCapacity);
00546     }
00547 }
00548 
00549 inline LocaleRuns::~LocaleRuns()
00550 {
00551     if (! fClientArrays) {
00552         LE_DELETE_ARRAY(fLocales);
00553         fLocales = NULL;
00554     }
00555 }
00556 
00562 class U_LAYOUTEX_API ValueRuns : public RunArray
00563 {
00564 public:
00577     ValueRuns(const le_int32 *values, const le_int32 *limits, le_int32 count);
00578 
00590     ValueRuns(le_int32 initialCapacity);
00591 
00597     virtual ~ValueRuns();
00598 
00612     le_int32 getValue(le_int32 run) const;
00613 
00614 
00636     le_int32 add(le_int32 value, le_int32 limit);
00637 
00643     virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); }
00644 
00650     static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; }
00651 
00652 protected:
00653     virtual void init(le_int32 capacity);
00654     virtual void grow(le_int32 capacity);
00655 
00656 private:
00657 
00658         ValueRuns();
00659         ValueRuns(const ValueRuns &other);
00660         ValueRuns &operator=(const ValueRuns & /*other*/) { return *this; };
00661 
00666     static const char fgClassID;
00667 
00668     const le_int32 *fValues;
00669 };
00670 
00671 inline ValueRuns::ValueRuns()
00672         : RunArray(0), fValues(NULL)
00673 {
00674         // nothing else to do...
00675 }
00676 
00677 inline ValueRuns::ValueRuns(const ValueRuns & /*other*/)
00678         : RunArray(0), fValues(NULL)
00679 {
00680         // nothing else to do...
00681 }
00682 
00683 inline ValueRuns::ValueRuns(const le_int32 *values, const le_int32 *limits, le_int32 count)
00684     : RunArray(limits, count), fValues(values)
00685 {
00686     // nothing else to do...
00687 }
00688 
00689 inline ValueRuns::ValueRuns(le_int32 initialCapacity)
00690     : RunArray(initialCapacity), fValues(NULL)
00691 {
00692     if (initialCapacity > 0) {
00693         fValues = LE_NEW_ARRAY(le_int32, initialCapacity);
00694     }
00695 }
00696 
00697 inline ValueRuns::~ValueRuns()
00698 {
00699     if (! fClientArrays) {
00700         LE_DELETE_ARRAY(fValues);
00701         fValues = NULL;
00702     }
00703 }
00704 
00705 U_NAMESPACE_END
00706 #endif

Generated on Thu Jun 12 13:09:08 2003 for ICU 2.6 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001