FARGOS/VISTA Object Management Environment Core  ..
FARGOS/VISTA Object Management Environment Core Table of Contents
OMEnlm.h
Go to the documentation of this file.
1 #ifndef _OME_NLM_H
2 #define _OME_NLM_H "$Id: OMEnlm.h 312 2020-03-21 21:25:35Z geoff $"
4 
15 # include <OMEarray.h>
16 
17 // OMEnlmStorage is used internally by OMEnlm, thus all of its
18 // members are private and OMEnlm is listed as a friend.
19 
22 class OMEnlmStorage final : public OMEreferenceCount
23 {
24  friend class OMEnlm;
26 
27 private:
31  // possible extras: debug filter flag
33 
34  // default initializer
35  OMEnlmStorage();
36 
37  explicit OMEnlmStorage(const class OMEstring &defaultMess,
38  OMEarray *args = nullptr,
39  const class OMEbaseType *id = nullptr,
40  const class OMEstring *catName = nullptr,
41  OMEarray *extras = nullptr);
42 
43  // destructor
45 
46  OMEstring *encodeNLM(const class OMEencodeBuffer *bfr) const;
47 
48  // SHOULD NEVER BE CALLED: NLM's are immutable...
49  virtual OMEreferenceCount *deepCopy() const override
50  {
51  std::cerr << "OMEnlmStorage::deepCopy called!\n";
52  return ((OMEnlmStorage *) this);
53  }
54 
55  bool operator==(const OMEnlmStorage &arg) const;
56 
57  bool operator!=(const OMEnlmStorage &arg) const;
58 
59  void getMessageInfo(OMEarray &list) const;
60 
61  // OMEbaseType &operator[](const uint32_t);
62  const OMEbaseType &operator[](const OMEarray::ARRAY_SUBSCRIPT_t i) const
63  {
64  return (messageArguments[i]);
65  }
66 
67  // int deleteIndex(const uint32_t);
69  {
70  return (messageArguments.indexExists(i));
71  }
72 
74  {
75  return (messageArguments.nextIndex(currentSubscript));
76  }
77 
78  uint_fast32_t elementCount() const
79  {
80  return (messageArguments.elementCount());
81  }
82 
83  bool isEmpty() const
84  {
85  return (messageArguments.isEmpty());
86  }
87 
88  const OMEstring &getMessageText(const OMEstring *lang = nullptr) const;
89 
90 
91  template <typename STREAMTYPE> STREAMTYPE &outputOnStream(STREAMTYPE &outputStream, int_fast16_t indent = 0,
92  uint8_t includeTypePrefix = OME_DEFAULT_COMPLEX_OUTPUT_MODE,
93  const OMEstring *lang = nullptr) const;
94 }; // end class OMEnlmStorage
95 
98 class OME_DLL_EXPORT OMEnlm final : public OMEreferenceToData<OMEnlmStorage>
99 {
100 private:
101  explicit OMEnlm(OMEnlmStorage *s)
102  {
103  // only used by deepCopy()
104  data = s;
105  // addReadOnlyReference();
106  }
107 
108 public:
109  static OMEnlm *decodeNLM(uint32_t ver, const OMEstring *encodedData,
110  size_t *offset);
111 
112  template <typename STREAMTYPE> static STREAMTYPE &outputFormattedData(STREAMTYPE &o,
113  const class OMEbaseType &data,
114  const class OMEbaseType &annotation,
115  const char *fieldModifier, int modifierLen);
116 
117  // NO DEFAULT INITIALIZER
118  // copy initializer
120  {
121 // data = org.data;
122 // addReadOnlyReference();
123  }
124 
125  explicit OMEnlm(const OMEstring &defaultMess, OMEarray *args = nullptr,
126  const OMEbaseType *id = nullptr, const OMEstring *catName = nullptr,
127  OMEarray *extra = nullptr)
128  {
129  data = new OMEnlmStorage(defaultMess, args, id, catName, extra);
130 // addReadOnlyReference();
131  }
132 
133  explicit OMEnlm(const char *m)
134  {
135  OMEstring s(m);
136 
137  data = new OMEnlmStorage(s);
138 // addReadOnlyReference();
139  }
140 
141  // assignment
142  OMEnlm &operator=(const OMEnlm &arg)
143  {
144  if (this->data == arg.data) {
145  std::cerr << "OMEnlm assignment to self, ref=" << totalReferences() << "\n";
146  return (*this); // asignment to self...
147  }
148  arg.data->addReadOnlyReference();
149  dropReference();
150  data = arg.data;
151  return (*this);
152  }
153 
154  ~OMEnlm() {}
155 
156  OMEstring *encodeNLM(const class OMEencodeBuffer *bfr) const
157  {
158  return (data->encodeNLM(bfr));
159  };
160 
161  // COMPARISON
162  bool operator==(const OMEnlm &arg) const
163  {
164  if (data == arg.data) {
165  return (true); // fast path
166  }
167  return (*data == *arg.data);
168  }
169 
170  bool operator!=(const OMEnlm &arg) const
171  {
172  if (data == arg.data) {
173  return (false); // fast path
174  }
175  return (*data != *arg.data);
176  }
177 
178  void getMessageInfo(OMEarray &list) const
179  {
180  data->getMessageInfo(list);
181  }
182 
183 # ifdef DO_WRITEABLE
184  OMEbaseType &operator[](const OMEarray::ARRAY_SUBSCRIPT_t i)
185  {
187  return ((*data)[i]);
188  }
189 # endif
190 
191  const OMEbaseType &operator[](const OMEarray::ARRAY_SUBSCRIPT_t i) const
192  {
193  const OMEnlmStorage &a = *data;
194  return (a[i]);
195  }
196 # ifdef DO_WRITEABLE
198  {
199  return (data->deleteIndex(i));
200  }
201 # endif
203  {
204  return (data->indexExists(i));
205  }
206 
208  {
209  return (data->nextIndex(currentSubscript));
210  }
211 
212  uint_fast32_t elementCount() const
213  {
214  return (data->elementCount());
215  }
216 
217  bool isEmpty() const
218  {
219  return (data->isEmpty());
220  }
221 
222  OMEnlm *deepCopy() const
223  {
224 
225  OMEnlmStorage *storageCopy = static_cast<OMEnlmStorage *>(data->deepCopy());
226  OMEnlm *copy = new OMEnlm(storageCopy);
227  return (copy);
228  }
229 
242  template <typename STREAMTYPE> STREAMTYPE &outputOnStream(STREAMTYPE &outputStream, int_fast16_t indent = 0, uint8_t includeTypePrefix = OME_DEFAULT_COMPLEX_OUTPUT_MODE,
243  const OMEstring *lang = nullptr) const
244  {
245  data->outputOnStream(outputStream, indent, includeTypePrefix, lang);
246  return (outputStream);
247  }
248 }; // end class OMEnlm
249 
252 template <typename STREAMTYPE> inline STREAMTYPE &operator<<(STREAMTYPE &outputStream, const OMEnlm &data)
253 {
254  data.outputOnStream(outputStream, 0);
255  return (outputStream);
256 }
257 
261 #endif
262 /* vim: set expandtab shiftwidth=4 tabstop=4: */
OMEencodeBuffer::condenseIntoString
OMEstring * condenseIntoString(bool includeVersionID)
Serialize all OMEencodeBufferElement items into a single string.
Definition: OMEencode.cpp:75
OMEnlm::encodeNLM
OMEstring * encodeNLM(const class OMEencodeBuffer *bfr) const
Definition: OMEnlm.h:156
OME_NLM
@ OME_NLM
Definition: OMEmanifests.h:90
OMEnlmStorage::elementCount
uint_fast32_t elementCount() const
Definition: OMEnlm.h:78
OMEnlmStorage::operator!=
bool operator!=(const OMEnlmStorage &arg) const
Definition: OMEnlm.cpp:71
OME_DELETE_OBJECT
#define OME_DELETE_OBJECT(ptr)
Definition: OMEmanifests.h:159
OMEnlmData
Identifier for an OME Native Language Message.
Definition: OMEnlmData.h:46
s
const char s[]
Definition: t.cpp:4
OMEnlm::operator=
OMEnlm & operator=(const OMEnlm &arg)
Definition: OMEnlm.h:142
OMEnlmData::catalogName
OMEstring catalogName
Definition: OMEnlmData.h:54
OMEnlmStorage::nextIndex
OMEarray::ARRAY_SUBSCRIPT_t nextIndex(const OMEarray::ARRAY_SUBSCRIPT_t currentSubscript) const
Definition: OMEnlm.h:73
OMEnlmStorage::~OMEnlmStorage
~OMEnlmStorage()
Definition: OMEnlm.cpp:31
OMEnlm::~OMEnlm
~OMEnlm()
Definition: OMEnlm.h:154
OMEnlm::nextIndex
OMEarray::ARRAY_SUBSCRIPT_t nextIndex(const OMEarray::ARRAY_SUBSCRIPT_t currentSubscript) const
Definition: OMEnlm.h:207
OMEnlmStorage::deepCopy
virtual OMEreferenceCount * deepCopy() const override
Definition: OMEnlm.h:49
OMEnlmStorage::outputOnStream
STREAMTYPE & outputOnStream(STREAMTYPE &outputStream, int_fast16_t indent=0, uint8_t includeTypePrefix=OME_DEFAULT_COMPLEX_OUTPUT_MODE, const OMEstring *lang=nullptr) const
Definition: OMEoutputOnStream.h:99
OMEnlmStorage::isEmpty
bool isEmpty() const
Definition: OMEnlm.h:83
OMEstring
Implements text and binary string storage.
Definition: OMEstring.h:305
OMEencode.h
OME type encoding routines.
OMEencodeBuffer
Buffer into which OMEtype data is encoded.
Definition: OMEencode.h:54
OMEreferenceToData::data
C * data
Definition: OMErefCount.h:82
OMEarray::indexExists
bool indexExists(const uint32_t i) const
Definition: OMEarray.h:202
OMEtype::value
union OMEtype::@26 value
OMEtype
Fundamental ANY type for FARGOS/VISTA Object Management Environment.
Definition: OMEbaseType.h:250
decodeData
int decodeData(OMEthread *thread, OMEtype &result, const OMEtype &data)
Definition: OILencode.cpp:61
_OME_NLM_H
#define _OME_NLM_H
Definition: tmp.o.cpp:970
OMEnlmStorage::messageData
class OMEnlmData * messageData
Definition: OMEnlm.h:28
OMEnlm::operator==
bool operator==(const OMEnlm &arg) const
Definition: OMEnlm.h:162
OMEtype::s
class OMEstring * s
Definition: OMEbaseType.h:299
OMEnlmStorage::debugLevel
int debugLevel
Definition: OMEnlm.h:32
OMEnlmStorage
Referenced-counted storage for an OME Native Language Message.
Definition: OMEnlm.h:22
OMEreferenceToData
Templated type-specific reference to a reference-counted object.
Definition: OMErefCount.h:79
OMEtype::decode
static OMEtype * decode(const class OMEstring *data, size_t *offset, const uint32_t version=0)
Decode an OMEtype previously encoded via encode().
Definition: OMEencode.cpp:204
OMEnlmData::getMessage
const OMEstring & getMessage(const OMEstring *lang=nullptr) const
Definition: OMEnlmData.cpp:570
OMEreferenceCount
Base class for reference-counted data.
Definition: OMErefCount.h:31
OMEnlm
Public interface to an OME Native Language Message.
Definition: OMEnlm.h:98
OMEnlm::OMEnlm
OMEnlm(const OMEstring &defaultMess, OMEarray *args=nullptr, const OMEtype *id=nullptr, const OMEstring *catName=nullptr, OMEarray *extra=nullptr)
Definition: OMEnlm.h:125
OMEreferenceToData::totalReferences
int_fast32_t totalReferences() const OME_ALWAYS_INLINE
Get current reference total.
Definition: OMErefCount.h:141
OMEnlmData::defaultMessage
OMEstring defaultMessage
Definition: OMEnlmData.h:52
OMEnlmStorage::OMEnlmStorage
OMEnlmStorage()
Definition: OMEnlm.cpp:10
srcID
const char srcID[]
Definition: catSym.c:17
OMEnlm::indexExists
bool indexExists(const OMEarray::ARRAY_SUBSCRIPT_t i) const
Definition: OMEnlm.h:202
OMEnlm::decodeNLM
static OMEnlm * decodeNLM(uint32_t ver, const OMEstring *encodedData, size_t *offset)
Definition: OMEnlm.cpp:140
OMEnlmStorage::encodeNLM
OMEstring * encodeNLM(const class OMEencodeBuffer *bfr) const
Definition: OMEnlm.cpp:96
operator<<
STREAMTYPE & operator<<(STREAMTYPE &outputStream, const OMEnlm &data)
Output an OMEnlm object to an output stream.
Definition: OMEnlm.h:252
OMEencodeBuffer::addEncodedElement
void addEncodedElement(OMEencodeBufferElement *elem)
Append an encoded element to the collection.
Definition: OMEencode.h:84
OMEnlm::getMessageInfo
void getMessageInfo(OMEarray &list) const
Definition: OMEnlm.h:178
deleteIndex
int deleteIndex(OMEthread *thread, OMEtype &result, const OMEtype &array, const OMEtype &subscript)
Definition: OILtypeFuncs.cpp:452
OME_NIL
@ OME_NIL
Definition: OMEmanifests.h:78
OMEnlm::operator[]
const OMEtype & operator[](const OMEarray::ARRAY_SUBSCRIPT_t i) const
Definition: OMEnlm.h:191
OMEnlmData::messageID
OMEtype messageID
Definition: OMEnlmData.h:53
OMEtype.h
OME fundamental type implementation.
OMEnlmStorage::argumentInfo
OMEarray argumentInfo
Definition: OMEnlm.h:30
OME_USED
const char srcID[] OME_USED
Definition: tick_time.cpp:24
OMEnlm::OMEnlm
OMEnlm(OMEnlmStorage *s)
Definition: OMEnlm.h:101
OMEnlm::OMEnlm
OMEnlm(const char *m)
Definition: OMEnlm.h:133
OMEarray::elementCount
uint_fast32_t elementCount() const OME_ALWAYS_INLINE
Definition: OMEarray.h:247
OMEnlmStorage::messageArguments
OMEarray messageArguments
Definition: OMEnlm.h:29
OMEnlmStorage::indexExists
bool indexExists(const OMEarray::ARRAY_SUBSCRIPT_t i) const
Definition: OMEnlm.h:68
OMEreferenceCount::addReadOnlyReference
void addReadOnlyReference()
Definition: OMErefCount.cpp:139
OMEarray::isEmpty
bool isEmpty() const OME_ALWAYS_INLINE
Definition: OMEarray.h:252
OMEnlmData.h
OME native language message catalog implementation.
OMEarray::nextIndex
ARRAY_SUBSCRIPT_t nextIndex(const uint32_t currentSubscript) const
Definition: OMEarray.h:217
OMEreferenceToData::dropReference
void dropReference(C *newData=nullptr) OME_ALWAYS_INLINE
Definition: OMErefCount.h:91
OMEarray.h
OME sparse array implementation.
OMEnlm::OMEnlm
OMEnlm(const OMEnlm &org)
Definition: OMEnlm.h:119
OMEreferenceToData::getUniqueReference
void getUniqueReference()
Force unique reference to the data, which will trigger duplication if necessary (copy-on-write).
Definition: OMErefCount.h:127
OME_DLL_EXPORT
#define OME_DLL_EXPORT
Definition: compiler_hints.h:464
OMEarray
Implements sparse array of OMEtype elements.
Definition: OMEarray.h:75
OMEnlmData::getMessageInfo
void getMessageInfo(OMEarray &list) const
Definition: OMEnlmData.h:70
OME_DEFAULT_COMPLEX_OUTPUT_MODE
@ OME_DEFAULT_COMPLEX_OUTPUT_MODE
Definition: OMEmanifests.h:116
OMEnlm::outputOnStream
STREAMTYPE & outputOnStream(STREAMTYPE &outputStream, int_fast16_t indent=0, uint8_t includeTypePrefix=OME_DEFAULT_COMPLEX_OUTPUT_MODE, const OMEstring *lang=nullptr) const
Output an OMEnlm object to an output stream.
Definition: OMEnlm.h:242
OMEnlm::isEmpty
bool isEmpty() const
Definition: OMEnlm.h:217
OMEencodeBufferElement
Holds data for a single encoded OMEtype element. Multiple OMEencodeBufferElement objects are linked t...
Definition: OMEencode.h:20
OME_ARRAY
@ OME_ARRAY
Definition: OMEmanifests.h:86
OMEnlm::deepCopy
OMEnlm * deepCopy() const
Definition: OMEnlm.h:222
OMEnlmStorage::getMessageInfo
void getMessageInfo(OMEarray &list) const
Definition: OMEnlm.cpp:36
OMEarray::ARRAY_SUBSCRIPT_t
OMEarrayStorage::ARRAY_SUBSCRIPT_t ARRAY_SUBSCRIPT_t
Definition: OMEarray.h:90
OMEnlm::operator!=
bool operator!=(const OMEnlm &arg) const
Definition: OMEnlm.h:170
OMEnlm::elementCount
uint_fast32_t elementCount() const
Definition: OMEnlm.h:212
OMEnlmStorage::operator[]
const OMEtype & operator[](const OMEarray::ARRAY_SUBSCRIPT_t i) const
Definition: OMEnlm.h:62
OMEnlmStorage::getMessageText
const OMEstring & getMessageText(const OMEstring *lang=nullptr) const
Definition: OMEnlm.cpp:41
OMEnlmStorage::operator==
bool operator==(const OMEnlmStorage &arg) const
Definition: OMEnlm.cpp:46
Generated: Fri Jul 31 2020 18:19:15
Support Information