FARGOS/VISTA Object Management Environment Core  ..
FARGOS/VISTA Object Management Environment Core Table of Contents
shared_variable.hpp
Go to the documentation of this file.
1 #ifndef _SHARED_VARIABLE_HPP_
2 #define _SHARED_VARIABLE_HPP_ "$Id: shared_variable.hpp 456 2020-07-23 20:25:49Z geoff $"
4 
6 /* Copyright (C) 2011 - 2020 FARGOS Development, LLC
7  * Author: Geoff Carpenter - http://www.fargos.net/gcc.html
8  */
9 
11 #include <stdint.h>
12 #include <string.h>
13 #include <list> //needed for deferredList
14 #include <typeinfo>
15 
17 #include <utils/io/mapped_file.h> // to pick up MAP_FILE defines for createSegment modes
18 
32 #define SMV_MAGIC_NUMBER "SHMVAR01"
34 
35 #pragma GCC diagnostic push
36 #pragma GCC diagnostic ignored "-Wsuggest-final-types"
37 
42 public:
54  SMV_TYPE_TINY_STRING=16, // 7 or less chars + null
59  };
60 
61  enum {
66  };
67 
75  /* WARNING: it is MANDATORY that numericValue be at offset 0 */
76  union {
77  uint64_t u64;
78  int64_t i64;
79  int32_t i32;
80  uint32_t u32;
81  float f;
82  double d;
83  char tinyString[8];
84  } numericValue; /* 8 bytes, must be at offset 0 */
85  uint64_t parentNodeOffset;
86  uint32_t allocatedLength;
87  uint32_t usedLength;
88  uint16_t recordType;
89  uint16_t varNameLength;
90  char varName[12 + sizeof(SharedBufferAllocRecord)];
91 
93  char *formatAsText(char *bfr, uint_fast32_t bfrLen, uint_fast32_t displayMode,
94  const char *pathPrefix=nullptr, bool isNative=true) const;
95 
97  int getPathPrefix(char *bfr, uint_fast32_t bfrLen, unsigned char *base, bool isNative=true) const;
98 
99  };
100 protected:
102 
106  const char *variableName;
107  uint32_t minLength;
108  unsigned char dataType;
109  unsigned char registered;
110  unsigned char _pad1[2];
111 
112 public:
114  return (parentNodeRecord);
115  }
116 
118  return (variableManager);
119  }
120 
122  static const char *typeName(unsigned int t) OME_CONST_FUNCTION;
123 
125  unsigned int getType() const OME_ALWAYS_INLINE {
126  return (dataType);
127  }
128 
130  unsigned int getMinLength() const OME_ALWAYS_INLINE {
131  return (minLength);
132  }
133 
135  const char *getName(uint_fast32_t *retNameLen=nullptr) const OME_ALWAYS_INLINE {
137  if (retNameLen != nullptr) {
138  *retNameLen = dataPointer->varNameLength;
139  }
140  return (dataPointer->varName);
141  } else { // not yet allocated
142  if (retNameLen != nullptr) {
143  *retNameLen = strlen(variableName);
144  }
145  return (variableName);
146  }
147  }
148 
150  int setName(const char *newName) {
151  variableName = newName;
152  if (registered) {
153  strncpy(dataPointer->varName, newName, dataPointer->varNameLength);
154  }
155  return (registered);
156  }
157 
159  uint_fast32_t getFullName(char *bfr, uint_fast32_t bfrLen) const;
160 
165  const char *varName, int varType, size_t length);
166 
168  const char *varName, int varType, size_t length);
169 
170  virtual ~SharedMemoryVariable();
171 
177 
180  }
181 
182 }; // end class SharedMemoryVariable
183 #pragma GCC diagnostic pop
184 
194 protected:
195  typedef std::list<SharedMemoryVariable *> smv_list_t;
196 
199  unsigned char *regionBase;
200  size_t regionLength;
201 
206 
211 
212 public:
226  static unsigned char *createSegment(const char *fileName,
227  size_t *segmentLengthPtr, int initMode = MAP_FILE_INIT,
228  const char *desiredMagicNumber = SMV_MAGIC_NUMBER);
229 
237  void attachExistingSegment(unsigned char *segment,
238  size_t segmentLength);
239 
249 
257  void initializeSegment(unsigned char *segment, size_t segmentLength,
258  const char *componentName);
259 
268  void initializeSegment(BufferRegion *bfr);
269 
274  unsigned char *createAndAttachStandardSegment(const char *componentName,
275  size_t *segmentLength);
276 
282  explicit SharedMemoryVariableManager(bool inDataSegment=true);
283 
285 
287 
289 
291 
293  size_t result = reinterpret_cast<const unsigned char *>(rec) -
295  return (result);
296  }
297 
298  inline bool initialized() const OME_ALWAYS_INLINE { return (bfrMgr != nullptr); }
299 
302 
304  void registerVariables(int count, SharedMemoryVariable *vars[]);
305 }; // end class SharedMemoryVariableManager
306 
307 
310 
319 {
320 public:
321  explicit SharedMemoryVariableNode(const char *varName,
323  SharedMemoryVariable(mgr, varName,
324  SMV_TYPE_NAME_NODE, strlen(varName)) {}
325 
326  SharedMemoryVariableNode(const char *varName,
327  SharedMemoryVariableNode *parentNode) :
328  SharedMemoryVariable(parentNode, varName,
329  SMV_TYPE_NAME_NODE, strlen(varName)) {}
330 }; // end class SharedMemoryVariableNode
331 
332 
333 
337 template<typename NUMTYPE> class SMV_Numeric:
338  public SharedMemoryVariable
339 {
340 public:
341  explicit SMV_Numeric(const char *varName,
343  SharedMemoryVariable(mgr, varName,
344  typeid(NUMTYPE) == typeid(int32_t) ? SMV_TYPE_INT32 :
345  typeid(NUMTYPE) == typeid(uint32_t) ? SMV_TYPE_UINT32 :
346  typeid(NUMTYPE) == typeid(int64_t) ? SMV_TYPE_INT64 :
347  typeid(NUMTYPE) == typeid(uint64_t) ? SMV_TYPE_UINT64 :
348  typeid(NUMTYPE) == typeid(float) ? SMV_TYPE_FLOAT :
349  typeid(NUMTYPE) == typeid(double) ? SMV_TYPE_DOUBLE :
350  ~0, /* default if unknown */
351  sizeof(NUMTYPE)) {}
352 
353  SMV_Numeric(const char *varName,
355  SharedMemoryVariable(parentNode, varName,
356  typeid(NUMTYPE) == typeid(int32_t) ? SMV_TYPE_INT32 :
357  typeid(NUMTYPE) == typeid(uint32_t) ? SMV_TYPE_UINT32 :
358  typeid(NUMTYPE) == typeid(int64_t) ? SMV_TYPE_INT64 :
359  typeid(NUMTYPE) == typeid(uint64_t) ? SMV_TYPE_UINT64 :
360  typeid(NUMTYPE) == typeid(float) ? SMV_TYPE_FLOAT :
361  typeid(NUMTYPE) == typeid(double) ? SMV_TYPE_DOUBLE :
362  ~0, /* default if unknown */
363  sizeof(NUMTYPE)) {}
364 
365  /* WARNING: these all depend on SharedMemoryVariable_Record having
366  * the numeric field at offset 0
367  */
369  inline operator NUMTYPE() const OME_ALWAYS_INLINE {
370  return (*reinterpret_cast<const NUMTYPE *>(dataPointer));
371  }
372 
374  inline NUMTYPE *getAddress() const OME_ALWAYS_INLINE {
375  return (reinterpret_cast<NUMTYPE *>(dataPointer));
376  }
377 
379  inline explicit operator const NUMTYPE *() const OME_ALWAYS_INLINE {
380  return (reinterpret_cast<const NUMTYPE *>(dataPointer));
381  }
382 
384  inline NUMTYPE &operator=(const NUMTYPE arg) OME_ALWAYS_INLINE {
385  return (*reinterpret_cast<NUMTYPE *>(dataPointer) = arg);
386  }
387 
389  inline NUMTYPE &operator+=(const NUMTYPE arg) OME_ALWAYS_INLINE {
390  return (*reinterpret_cast<NUMTYPE *>(dataPointer) += arg);
391  }
392 
394  inline NUMTYPE &operator-=(const NUMTYPE arg) OME_ALWAYS_INLINE {
395  return (*reinterpret_cast<NUMTYPE *>(dataPointer) -= arg);
396  }
397 
399  inline NUMTYPE &operator*=(const NUMTYPE arg) OME_ALWAYS_INLINE {
400  return (*reinterpret_cast<NUMTYPE *>(dataPointer) *= arg);
401  }
402 
404  inline NUMTYPE &operator/=(const NUMTYPE arg) OME_ALWAYS_INLINE {
405  return (*reinterpret_cast<NUMTYPE *>(dataPointer) /= arg);
406  }
407 
409  inline NUMTYPE &operator++() OME_ALWAYS_INLINE {
410  return (*reinterpret_cast<NUMTYPE *>(dataPointer) += 1);
411  }
413  inline NUMTYPE &operator--() OME_ALWAYS_INLINE {
414  return (*reinterpret_cast<NUMTYPE *>(dataPointer) -= 1);
415  }
416 
418  inline NUMTYPE operator++(int) OME_ALWAYS_INLINE {
419  NUMTYPE result = *reinterpret_cast<NUMTYPE *>(dataPointer);
420  *reinterpret_cast<NUMTYPE *>(dataPointer) += 1;
421  return (result);
422  }
424  inline NUMTYPE operator--(int) OME_ALWAYS_INLINE {
425  NUMTYPE result = *reinterpret_cast<NUMTYPE *>(dataPointer);
426  *reinterpret_cast<NUMTYPE *>(dataPointer) -= 1;
427  return (result);
428  }
429 }; // end class SMV_Numeric
430 
436 template<typename NUMTYPE> class SMV_StandaloneNumeric:
437  public SharedMemoryVariable
438 {
439 protected:
441 public:
442  explicit SMV_StandaloneNumeric(const char *varName,
444  NUMTYPE initVal=0) NONNULL_CLASS_PARAMETERS(2) :
445  SharedMemoryVariable(mgr, varName,
446  typeid(NUMTYPE) == typeid(int32_t) ? SMV_TYPE_INT32 :
447  typeid(NUMTYPE) == typeid(uint32_t) ? SMV_TYPE_UINT32 :
448  typeid(NUMTYPE) == typeid(int64_t) ? SMV_TYPE_INT64 :
449  typeid(NUMTYPE) == typeid(uint64_t) ? SMV_TYPE_UINT64 :
450  typeid(NUMTYPE) == typeid(float) ? SMV_TYPE_FLOAT :
451  typeid(NUMTYPE) == typeid(double) ? SMV_TYPE_DOUBLE :
452  ~0, /* default if unknown */
453  sizeof(NUMTYPE))
454  {
455  // NOTE: dataPointer will be set by base class SharedMemoryVariable,
456  // which gets constructed first
457  if (dataPointer == nullptr) {
459  }
460  *this = initVal;
461  }
462 
463  SMV_StandaloneNumeric(const char *varName,
464  SharedMemoryVariableNode *parentNode, NUMTYPE initVal=0) :
465  SharedMemoryVariable(parentNode, varName,
466  typeid(NUMTYPE) == typeid(int32_t) ? SMV_TYPE_INT32 :
467  typeid(NUMTYPE) == typeid(uint32_t) ? SMV_TYPE_UINT32 :
468  typeid(NUMTYPE) == typeid(int64_t) ? SMV_TYPE_INT64 :
469  typeid(NUMTYPE) == typeid(uint64_t) ? SMV_TYPE_UINT64 :
470  typeid(NUMTYPE) == typeid(float) ? SMV_TYPE_FLOAT :
471  typeid(NUMTYPE) == typeid(double) ? SMV_TYPE_DOUBLE :
472  ~0, /* default if unknown */
473  sizeof(NUMTYPE))
474  {
475  if (dataPointer == nullptr) {
477  }
478  *this = initVal;
479  }
480 
481  /* WARNING: these all depend on SharedMemoryVariable_Record having
482  * the numeric field at offset 0
483  */
485  inline operator NUMTYPE() const OME_ALWAYS_INLINE {
486  return (*reinterpret_cast<const NUMTYPE *>(dataPointer));
487  }
488 
490  inline NUMTYPE *getAddress() const OME_ALWAYS_INLINE {
491  return (reinterpret_cast<NUMTYPE *>(dataPointer));
492  }
493 
495  inline explicit operator const NUMTYPE *() const OME_ALWAYS_INLINE {
496  return (reinterpret_cast<const NUMTYPE *>(dataPointer));
497  }
498 
500  inline NUMTYPE &operator=(const NUMTYPE arg) OME_ALWAYS_INLINE {
501  return (*reinterpret_cast<NUMTYPE *>(dataPointer) = arg);
502  }
503 
505  inline NUMTYPE &operator+=(const NUMTYPE arg) OME_ALWAYS_INLINE {
506  return (*reinterpret_cast<NUMTYPE *>(dataPointer) += arg);
507  }
508 
510  inline NUMTYPE &operator-=(const NUMTYPE arg) OME_ALWAYS_INLINE {
511  return (*reinterpret_cast<NUMTYPE *>(dataPointer) -= arg);
512  }
513 
515  inline NUMTYPE &operator*=(const NUMTYPE arg) OME_ALWAYS_INLINE {
516  return (*reinterpret_cast<NUMTYPE *>(dataPointer) *= arg);
517  }
518 
520  inline NUMTYPE &operator/=(const NUMTYPE arg) OME_ALWAYS_INLINE {
521  return (*reinterpret_cast<NUMTYPE *>(dataPointer) /= arg);
522  }
523 
525  inline NUMTYPE &operator++() OME_ALWAYS_INLINE {
526  return (*reinterpret_cast<NUMTYPE *>(dataPointer) += 1);
527  }
529  inline NUMTYPE &operator--() OME_ALWAYS_INLINE {
530  return (*reinterpret_cast<NUMTYPE *>(dataPointer) -= 1);
531  }
532 
534  inline NUMTYPE operator++(int) OME_ALWAYS_INLINE {
535  NUMTYPE result = *reinterpret_cast<NUMTYPE *>(dataPointer);
536  *reinterpret_cast<NUMTYPE *>(dataPointer) += 1;
537  return (result);
538  }
540  inline NUMTYPE operator--(int) OME_ALWAYS_INLINE {
541  NUMTYPE result = *reinterpret_cast<NUMTYPE *>(dataPointer);
542  *reinterpret_cast<NUMTYPE *>(dataPointer) -= 1;
543  return (result);
544  }
545 
546  virtual void noteNowRegistered(SharedMemoryVariable_Record *newArea) override {
547  // copy any existing counts into allocated storage area
548  *reinterpret_cast<NUMTYPE *>(newArea) =
549  *reinterpret_cast<NUMTYPE *>(dataPointer);
550  }
551 }; // end class SMV_StandaloneNumeric
552 
553 
557  public SharedMemoryVariable
558 {
559 public:
560  SMV_String(const char *varName, size_t reservedLength,
562  SharedMemoryVariable(mgr, varName, SMV_TYPE_STRING, reservedLength) {};
563 
564  SMV_String(const char *varName, size_t reservedLength,
566  SharedMemoryVariable(parentNode, varName, SMV_TYPE_STRING,
567  reservedLength) {};
568 
570  inline operator const char *() const OME_ALWAYS_INLINE {
572  };
573 
575  inline char *operator=(const char *val) OME_ALWAYS_INLINE {
576  // TODO: either externalize the overhead of a record or make
577  // allocatedLength not include any recording keeping overhead.
578  // The FixedBufferManager prefixes the data block with the allocation
579  // record, whereas the CircularBufferManager keeps allocation records
580  // separate from data records.
581  const uint32_t headerOverhead = (sizeof(SharedMemoryVariable_Record) -
582  sizeof(dataPointer->varName)) +
583  sizeof(SharedBufferAllocRecord); // TODO: this depends on storage mode
584  size_t avail = dataPointer->allocatedLength -
585  (headerOverhead + dataPointer->varNameLength);
587  char *n = (char *) memccpy(d, val, '\0', avail);
588  if (OME_EXPECT_FALSE(n == nullptr)) {
589  dataPointer->usedLength = avail;
590  } else {
591  dataPointer->usedLength = (n - d);
592  }
593  return (d);
594  }
595 }; // end class SMV_String
596 
597 
608 template <size_t MAXLEN> class SMV_StandaloneString:
609  public SharedMemoryVariable
610 {
611 protected:
612  union {
615  } space;
616 public:
617  explicit SMV_StandaloneString(const char *varName,
619  SharedMemoryVariable(mgr, varName, SMV_TYPE_STRING, MAXLEN)
620  {
621  if (dataPointer == nullptr) {
622  memset(&space, 0, sizeof(space));
623  dataPointer = &space.initialCopy;
624  safe_strcpy(dataPointer->varName, varName, sizeof(dataPointer->varName));
625  dataPointer->varNameLength = static_cast<uint16_t>(strlen(varName) + 1);
626  dataPointer->allocatedLength = sizeof(space);
627  }
628  }
629 
630  SMV_StandaloneString(const char *varName, SharedMemoryVariableNode *parentNode) :
631  SharedMemoryVariable(parentNode, varName, SMV_TYPE_STRING, MAXLEN)
632  {
633  if (dataPointer == nullptr) {
634  memset(&space, 0, sizeof(space));
635  dataPointer = &space.initialCopy;
636  dataPointer->varNameLength = strlen(varName) + 1;
637  dataPointer->allocatedLength = sizeof(space);
638  }
639  }
640 
642  inline operator const char *() const OME_ALWAYS_INLINE {
644  };
645 
647  inline char *operator=(const char *val) OME_ALWAYS_INLINE {
648  // TODO: either externalize the overhead of a record or make
649  // allocatedLength not include any recording keeping overhead.
650  // The FixedBufferManager prefixes the data block with the allocation
651  // record, whereas the CircularBufferManager keeps allocation records
652  // separate from data records.
653  const uint32_t headerOverhead = (sizeof(SharedMemoryVariable_Record) -
654  sizeof(dataPointer->varName)) +
655  sizeof(SharedBufferAllocRecord); // TODO: this depends on storage mode
656  size_t avail = dataPointer->allocatedLength -
657  (headerOverhead + dataPointer->varNameLength);
659  char *n = (char *) memccpy(d, val, '\0', avail);
660  if (OME_EXPECT_FALSE(n == nullptr)) {
661  dataPointer->usedLength = avail;
662  } else {
663  dataPointer->usedLength = (n - d);
664  }
665  return (d);
666  }
667 
668  virtual void noteNowRegistered(SharedMemoryVariable_Record *newArea) override {
669  // copy any string into allocated storage area
670  const uint32_t headerOverhead = (sizeof(SharedMemoryVariable_Record) -
671  sizeof(dataPointer->varName)) +
672  sizeof(SharedBufferAllocRecord); // TODO: this depends on storage mode
673  size_t avail = newArea->allocatedLength -
674  (headerOverhead + newArea->varNameLength);
675  char *d = newArea->varName + newArea->varNameLength;
677  char *n = (char *) memccpy(d, s, '\0', avail);
678  if (OME_EXPECT_FALSE(n == nullptr)) {
679  newArea->usedLength = avail;
680  } else {
681  newArea->usedLength = (n - d);
682  }
683  }
684 }; // end class SMV_StandaloneString:
685 
695 template <size_t MAXLEN> class SMV_StandaloneNode :
697 {
698 protected:
699  char reservedSpace[MAXLEN];
700 
701 public:
702  explicit SMV_StandaloneNode(const char *varName,
704  SharedMemoryVariableNode(varName, mgr)
705  {
706  safe_strcpy(reservedSpace, varName, sizeof(reservedSpace));
708  }
709 
710  SMV_StandaloneNode(const char *varName,
711  SharedMemoryVariableNode *parentNode) :
712  SharedMemoryVariableNode(varName, parentNode)
713  {
714  safe_strcpy(reservedSpace, varName, sizeof(reservedSpace));
716  }
717 }; // end class SMV_StandaloneNode
718 
724 #define DECLARE_SMV_COUNTER(name) SMV_Numeric<uint32_t> name(#name)
725 
726 
728 #endif
729 /* vim: set expandtab shiftwidth=4 tabstop=4: */
unallocated_data
SharedMemoryVariable::SharedMemoryVariable_Record unallocated_data
Definition: shared_variable.cpp:37
FixedBufferManager
Impose a fixed-size buffer on a BufferRegion.
Definition: circular_bfr.hpp:356
SharedMemoryVariableManager::~SharedMemoryVariableManager
~SharedMemoryVariableManager()
Definition: shared_variable.cpp:329
safe_strcpy
#define safe_strcpy(d, s, l)
Safe strcpy() routine that will not copy more than l bytes and always ensures that a null is present ...
Definition: compiler_hints.h:696
SMV_StandaloneNumeric::SMV_StandaloneNumeric
SMV_StandaloneNumeric(const char *varName, SharedMemoryVariableManager *mgr=&DEFAULT_sharedMemoryVariableManager, NUMTYPE initVal=0) NONNULL_CLASS_PARAMETERS(2)
Definition: shared_variable.hpp:442
MAP_FILE_RESET
#define MAP_FILE_RESET
Definition: mapped_file.h:68
SharedMemoryVariable::SharedMemoryVariable_Record::f
float f
Definition: shared_variable.hpp:81
Maj
#define Maj(x, y, z)
Definition: sha256.cpp:41
SharedMemoryVariable::getName
const char * getName(uint_fast32_t *retNameLen=nullptr) const OME_ALWAYS_INLINE
Get variable name.
Definition: shared_variable.hpp:135
sharedBufferSegmentIsInNativeByteOrder
bool sharedBufferSegmentIsInNativeByteOrder(const void *segment)
Indicates if segment uses native byte order.
Definition: circular_bfr.hpp:90
SharedMemoryVariableManager::allocateDeferredVariables
void allocateDeferredVariables()
Internal routine to allocate previously registered SharedMemoryVariables within a newly allocated seg...
Definition: shared_variable.cpp:390
l
Ïúíþ ð Ø ˜ ˜ __text __TEXT € __apple_names __DWARF __apple_objc __DWARF __apple_namespac__DWARF H X __apple_types __DWARF l
Definition: tmp3.o.cpp:1
OME_INIT_PRIORITY
SharedMemoryVariableManager DEFAULT_sharedMemoryVariableManager OME_INIT_PRIORITY(105)(true)
SharedMemoryVariableManager::iterateOver64BitSegment
SharedMemoryVariable::SharedMemoryVariable_Record * iterateOver64BitSegment(SharedBufferAllocRecord_64 **iterator)
Definition: shared_variable.cpp:540
SharedMemoryVariable::SharedMemoryVariable_Record::i64
int64_t i64
Definition: shared_variable.hpp:78
SMV_StandaloneNode::SMV_StandaloneNode
SMV_StandaloneNode(const char *varName, SharedMemoryVariableNode *parentNode)
Definition: shared_variable.hpp:710
s
const char s[]
Definition: t.cpp:4
Ch
#define Ch(x, y, z)
Definition: sha256.cpp:40
SharedMemoryVariableManager::registerVariable
bool registerVariable(SharedMemoryVariable &var)
Register a single variable with the segment manager.
Definition: shared_variable.cpp:600
sha_init
HIDE_FUNCTION void sha_init(sha_state *md)
Definition: sha256.cpp:90
SMV_StandaloneString::initialCopy
SharedMemoryVariable::SharedMemoryVariable_Record initialCopy
Definition: shared_variable.hpp:613
SharedBufferRegionHeader_32::magicNumber
char magicNumber[8]
Definition: circular_bfr.hpp:44
SharedMemoryVariableManager::initialized
bool initialized() const OME_ALWAYS_INLINE
Definition: shared_variable.hpp:298
SharedBufferAllocRecord_32
Allocation record for chains in a 32-bit shared memory buffer.
Definition: circular_bfr.hpp:103
SharedMemoryVariable::SharedMemoryVariable_Record::usedLength
uint32_t usedLength
used length, always <= allocated length
Definition: shared_variable.hpp:87
SharedMemoryVariable::SharedMemoryVariable_Record::numericValue
union SharedMemoryVariable::SharedMemoryVariable_Record::@22 numericValue
SMV_StandaloneNumeric::operator*=
NUMTYPE & operator*=(const NUMTYPE arg) OME_ALWAYS_INLINE
Multiplication operator for a numeric shared memory variable.
Definition: shared_variable.hpp:515
OMEstring.h
OME string implementation.
SharedMemoryVariable::SMV_TYPE_INT64
@ SMV_TYPE_INT64
Definition: shared_variable.hpp:49
SharedMemoryVariable::~SharedMemoryVariable
virtual ~SharedMemoryVariable()
Definition: shared_variable.cpp:281
SMV_StandaloneString::space
union SMV_StandaloneString::@23 space
main
int main(int argc, const char *argv[])
Definition: s.cpp:18
SMV_StandaloneNumeric
Convenience template for creating shared memory variables of one of the supported numeric types....
Definition: shared_variable.hpp:436
SMV_String
Convenience class for string variables.
Definition: shared_variable.hpp:556
SharedMemoryVariable::getParentNode
SharedMemoryVariableNode * getParentNode() const
Definition: shared_variable.hpp:113
OMEstring
Implements text and binary string storage.
Definition: OMEstring.h:305
SMV_StandaloneNumeric::operator/=
NUMTYPE & operator/=(const NUMTYPE arg) OME_ALWAYS_INLINE
Division operator for a numeric shared memory variable.
Definition: shared_variable.hpp:520
SharedMemoryVariable::SMV_TYPE_DOUBLE
@ SMV_TYPE_DOUBLE
Definition: shared_variable.hpp:52
SharedMemoryVariable::SharedMemoryVariable_Record::allocatedLength
uint32_t allocatedLength
allocated length
Definition: shared_variable.hpp:86
SharedMemoryVariable::SharedMemoryVariable_Record::d
double d
Definition: shared_variable.hpp:82
SMV_StandaloneNumeric::operator++
NUMTYPE & operator++() OME_ALWAYS_INLINE
Prefix increment operator for a numeric shared memory variable.
Definition: shared_variable.hpp:525
SharedMemoryVariableManager::registerVariables
void registerVariables(int count, SharedMemoryVariable *vars[])
Register an array of variables with the segment manager.
Definition: shared_variable.cpp:621
SharedMemoryVariableManager::initializeSegment
void initializeSegment(unsigned char *segment, size_t segmentLength, const char *componentName)
Initialize a memory segment for use as variable storage.
Definition: shared_variable.cpp:406
SMV_StandaloneNumeric::noteNowRegistered
virtual void noteNowRegistered(SharedMemoryVariable_Record *newArea) override
Extension mechanism to allow derived classes to be informed when they are about to be assigned storag...
Definition: shared_variable.hpp:546
sha_process
HIDE_FUNCTION void sha_process(sha_state *md, const unsigned char *buf, size_t len)
Definition: sha256.cpp:103
MAP_FILE_INIT
#define MAP_FILE_INIT
Definition: mapped_file.h:69
SharedMemoryVariableNode
Intermediate naming node for supporting variable naming hierarchies.
Definition: shared_variable.hpp:318
SharedMemoryVariableManager::deferredList
smv_list_t * deferredList
Definition: shared_variable.hpp:197
our_swap16
uint16_t our_swap16(const void *byteData)
Definition: shared_variable.cpp:43
SharedMemoryVariable::typeName
static const char * typeName(unsigned int t) OME_CONST_FUNCTION
Return type as text string.
Definition: shared_variable.cpp:93
SMV_Numeric::operator--
NUMTYPE & operator--() OME_ALWAYS_INLINE
Prefix decrement operator for a numeric shared memory variable.
Definition: shared_variable.hpp:413
BufferRegion::getBufferBase
unsigned char * getBufferBase() const OME_ALWAYS_INLINE
Return the address of the buffer region.
Definition: circular_bfr.hpp:253
SharedMemoryVariable::SharedMemoryVariable_Record::recordType
uint16_t recordType
type of record, see SharedMemoryVariableType
Definition: shared_variable.hpp:88
SharedMemoryVariable::parentNodeRecord
class SharedMemoryVariableNode * parentNodeRecord
Definition: shared_variable.hpp:104
SharedMemoryVariableManager::iterateOver32BitSegment
SharedMemoryVariable::SharedMemoryVariable_Record * iterateOver32BitSegment(SharedBufferAllocRecord_32 **iterator)
Definition: shared_variable.cpp:514
NONNULL_CLASS_PARAMETERS
#define NONNULL_CLASS_PARAMETERS(...)
Mark a function as never returning a null pointer.
Definition: compiler_hints.h:337
SharedMemoryVariable::SMV_TYPE_STRING
@ SMV_TYPE_STRING
Definition: shared_variable.hpp:56
BufferRegion::getRegionLength
size_t getRegionLength() const OME_ALWAYS_INLINE
Return the number of bytes in the region.
Definition: circular_bfr.hpp:243
SharedMemoryVariable::makeAliasFor
void makeAliasFor(SharedMemoryVariable *v)
Definition: shared_variable.hpp:178
SMV_StandaloneNumeric::initialCopy
SharedMemoryVariable::SharedMemoryVariable_Record initialCopy
Definition: shared_variable.hpp:440
SMV_Numeric::operator-=
NUMTYPE & operator-=(const NUMTYPE arg) OME_ALWAYS_INLINE
Subtraction operator for a numeric shared memory variable.
Definition: shared_variable.hpp:394
SMV_StandaloneNumeric::operator=
NUMTYPE & operator=(const NUMTYPE arg) OME_ALWAYS_INLINE
Assignment operator for a numeric shared memory variable.
Definition: shared_variable.hpp:500
SharedMemoryVariable::SharedMemoryVariable_Record::u64
uint64_t u64
Definition: shared_variable.hpp:77
HIDE_FUNCTION
#define HIDE_FUNCTION
Definition: sha256.cpp:1
SharedMemoryVariable::dataType
unsigned char dataType
Definition: shared_variable.hpp:108
SMV_StandaloneString
Convenience class for string variables that can be also be used if a shared memory segment is never a...
Definition: shared_variable.hpp:608
SharedMemoryVariableManager::takeDeferredRegistrations
int takeDeferredRegistrations(SharedMemoryVariableManager *otherMgr)
Definition: shared_variable.cpp:565
SharedMemoryVariable::getMinLength
unsigned int getMinLength() const OME_ALWAYS_INLINE
Return minimum number of bytes required for variable record.
Definition: shared_variable.hpp:130
SMV_StandaloneString::SMV_StandaloneString
SMV_StandaloneString(const char *varName, SharedMemoryVariableManager *mgr=&DEFAULT_sharedMemoryVariableManager)
Definition: shared_variable.hpp:617
SharedMemoryVariable::SharedMemoryVariable_Record::tinyString
char tinyString[8]
Definition: shared_variable.hpp:83
S
#define S(x, n)
Definition: sha256.cpp:42
sha_done
HIDE_FUNCTION void sha_done(sha_state *md, unsigned char hash[32])
Definition: sha256.cpp:118
Sigma1
#define Sigma1(x)
Definition: sha256.cpp:45
SharedBufferAllocRecord_64::offset_nextInChain
uint64_t offset_nextInChain
Definition: circular_bfr.hpp:117
SharedBufferRegionHeader_32
Region header for a 32-bit shared memory segment.
Definition: circular_bfr.hpp:43
SMV_StandaloneString::reservedSpace
char reservedSpace[MAXLEN+sizeof(SharedMemoryVariable::SharedMemoryVariable_Record)]
Definition: shared_variable.hpp:614
SharedMemoryVariable::SharedMemoryVariable_Record::u32
uint32_t u32
Definition: shared_variable.hpp:80
SMV_StandaloneNumeric::operator+=
NUMTYPE & operator+=(const NUMTYPE arg) OME_ALWAYS_INLINE
Addition operator for a numeric shared memory variable.
Definition: shared_variable.hpp:505
SharedMemoryVariable::dataPointer
SharedMemoryVariable_Record * dataPointer
Definition: shared_variable.hpp:103
SMV_StandaloneString::SMV_StandaloneString
SMV_StandaloneString(const char *varName, SharedMemoryVariableNode *parentNode)
Definition: shared_variable.hpp:630
SMV_String::SMV_String
SMV_String(const char *varName, size_t reservedLength, SharedMemoryVariableNode *parentNode) NONNULL_CLASS_PARAMETERS(2)
Definition: shared_variable.hpp:564
SharedMemoryVariableNode::SharedMemoryVariableNode
SharedMemoryVariableNode(const char *varName, SharedMemoryVariableNode *parentNode)
Definition: shared_variable.hpp:326
OMEmakeSHA256hash
OMEstring * OMEmakeSHA256hash(const OMEstring &message)
Compute Secure Hash Algorithm 256 over an OMEstring.
Definition: sha256.cpp:169
SharedMemoryVariable::SMV_TYPE_FLOAT
@ SMV_TYPE_FLOAT
Definition: shared_variable.hpp:51
srcID
const char srcID[]
Definition: catSym.c:17
SharedMemoryVariableManager::SharedMemoryVariableManager
SharedMemoryVariableManager(bool inDataSegment=true)
Constructor for a shared memory variable manager.
Definition: shared_variable.cpp:317
SMV_Numeric::operator--
NUMTYPE operator--(int) OME_ALWAYS_INLINE
Postfix decrement operator for a numeric shared memory variable.
Definition: shared_variable.hpp:424
SharedMemoryVariable::getType
unsigned int getType() const OME_ALWAYS_INLINE
Return type of variable, see SharedMemoryVariableType.
Definition: shared_variable.hpp:125
Gamma0
#define Gamma0(x)
Definition: sha256.cpp:46
SMV_Numeric::operator++
NUMTYPE & operator++() OME_ALWAYS_INLINE
Prefix increment operator for a numeric shared memory variable.
Definition: shared_variable.hpp:409
SMV_StandaloneNumeric::SMV_StandaloneNumeric
SMV_StandaloneNumeric(const char *varName, SharedMemoryVariableNode *parentNode, NUMTYPE initVal=0)
Definition: shared_variable.hpp:463
SharedMemoryVariableManager::bfrMgr
BufferRegion * bfrMgr
Definition: shared_variable.hpp:198
SMV_StandaloneNumeric::operator--
NUMTYPE & operator--() OME_ALWAYS_INLINE
Prefix decrement operator for a numeric shared memory variable.
Definition: shared_variable.hpp:529
circular_bfr.hpp
mapped_file.h
DEFAULT_sharedMemoryVariableManager
SharedMemoryVariableManager DEFAULT_sharedMemoryVariableManager
Default shared memory variable manager.
SharedMemoryVariable::SMV_DISPLAY_NAME
@ SMV_DISPLAY_NAME
Definition: shared_variable.hpp:62
SharedMemoryVariableManager::createAndAttachStandardSegment
unsigned char * createAndAttachStandardSegment(const char *componentName, size_t *segmentLength)
Convenience function to create a file and map it to segment for variable storage. The filename will i...
Definition: shared_variable.cpp:426
OME_EXPECT_TRUE
#define OME_EXPECT_TRUE(expr)
Annotation macro for conditional expression expected to be true.
Definition: compiler_hints.h:541
SMV_StandaloneNode::SMV_StandaloneNode
SMV_StandaloneNode(const char *varName, SharedMemoryVariableManager *mgr=&DEFAULT_sharedMemoryVariableManager)
Definition: shared_variable.hpp:702
SMV_Numeric::SMV_Numeric
SMV_Numeric(const char *varName, SharedMemoryVariableNode *parentNode) NONNULL_CLASS_PARAMETERS(2)
Definition: shared_variable.hpp:353
SMV_StandaloneNumeric::operator-=
NUMTYPE & operator-=(const NUMTYPE arg) OME_ALWAYS_INLINE
Subtraction operator for a numeric shared memory variable.
Definition: shared_variable.hpp:510
SharedMemoryVariable::registered
unsigned char registered
Definition: shared_variable.hpp:109
SMV_Numeric
Convenience template for creating shared memory variables of one of the supported numeric types.
Definition: shared_variable.hpp:337
SharedMemoryVariable::SMV_TYPE_BINARY_STRING
@ SMV_TYPE_BINARY_STRING
Definition: shared_variable.hpp:57
SharedMemoryVariableManager::allocateVariable
void allocateVariable(SharedMemoryVariable *var)
Internal routine to allocate storage within the segment for a shared memory variable.
Definition: shared_variable.cpp:475
SharedMemoryVariable::SMV_DISPLAY_TYPE
@ SMV_DISPLAY_TYPE
Definition: shared_variable.hpp:64
SMV_StandaloneNode::reservedSpace
char reservedSpace[MAXLEN]
Definition: shared_variable.hpp:699
SharedBufferAllocRecord_32::offset_nextInChain
uint32_t offset_nextInChain
Definition: circular_bfr.hpp:108
sha_memory
HIDE_FUNCTION void sha_memory(const unsigned char *buf, size_t len, unsigned char hash[32])
Definition: sha256.cpp:158
GET32_NATIVE
#define GET32_NATIVE(fieldName, isNative)
Definition: shared_variable.cpp:25
SharedMemoryVariable::SharedMemoryVariableType
SharedMemoryVariableType
Definition: shared_variable.hpp:43
SharedMemoryVariable::unallocated_data
static SharedMemoryVariable_Record unallocated_data
Definition: shared_variable.hpp:101
SharedMemoryVariable::SMV_TYPE_NAME_NODE
@ SMV_TYPE_NAME_NODE
Definition: shared_variable.hpp:58
SMV_Numeric::getAddress
NUMTYPE * getAddress() const OME_ALWAYS_INLINE
Get address of shared memory variable.
Definition: shared_variable.hpp:374
SharedMemoryVariable::SMV_TYPE_FIXED
@ SMV_TYPE_FIXED
Definition: shared_variable.hpp:53
SharedMemoryVariableManager::smv_list_t
std::list< SharedMemoryVariable * > smv_list_t
Definition: shared_variable.hpp:195
createMappedFile
int createMappedFile(unsigned char **segment, const char *fileName, size_t *segmentLenPtr, uint_fast32_t doInit)
Create or open a mapped file with the specified file name.
Definition: mapped_file.cpp:207
SharedMemoryVariable::SMV_TYPE_INT32
@ SMV_TYPE_INT32
Definition: shared_variable.hpp:47
SMV_Numeric::operator*=
NUMTYPE & operator*=(const NUMTYPE arg) OME_ALWAYS_INLINE
Multiplication operator for a numeric shared memory variable.
Definition: shared_variable.hpp:399
OMEstring::length
size_t length() const
Definition: OMEstring.h:401
SMV_Numeric::operator=
NUMTYPE & operator=(const NUMTYPE arg) OME_ALWAYS_INLINE
Assignment operator for a numeric shared memory variable.
Definition: shared_variable.hpp:384
shared_variable.hpp
FARGOS Shared Memory Variable routines.
SharedMemoryVariableNode::SharedMemoryVariableNode
SharedMemoryVariableNode(const char *varName, SharedMemoryVariableManager *mgr=&DEFAULT_sharedMemoryVariableManager)
Definition: shared_variable.hpp:321
OME_USED
const char srcID[] OME_USED
Definition: tick_time.cpp:24
SMV_StandaloneString::noteNowRegistered
virtual void noteNowRegistered(SharedMemoryVariable_Record *newArea) override
Extension mechanism to allow derived classes to be informed when they are about to be assigned storag...
Definition: shared_variable.hpp:668
SMV_MAGIC_NUMBER
#define SMV_MAGIC_NUMBER
Magic number used for Shared Memory Variable segments.
Definition: shared_variable.hpp:33
SharedMemoryVariable::minLength
uint32_t minLength
Definition: shared_variable.hpp:107
SharedMemoryVariable::variableName
const char * variableName
Definition: shared_variable.hpp:106
OME_CONST_FUNCTION
#define OME_CONST_FUNCTION
Mark as an idempotent function that only accesses arguments – no global data.
Definition: compiler_hints.h:390
Gamma1
#define Gamma1(x)
Definition: sha256.cpp:47
atomic_values.h
Atomic operations.
SharedMemoryVariableManager
Manager for collection of shared memory variables.
Definition: shared_variable.hpp:193
SMV_StandaloneNode
Subclass of SharedMemoryVariableNode that reserves heap space to hold data when a shared memory segme...
Definition: shared_variable.hpp:695
SharedMemoryVariable::SharedMemoryVariable_Record
Storage layout for shared memory variable record within a memory mapped segment.
Definition: shared_variable.hpp:74
SharedMemoryVariable::SMV_DISPLAY_VALUE
@ SMV_DISPLAY_VALUE
Definition: shared_variable.hpp:63
SharedMemoryVariable::SharedMemoryVariable_Record::parentNodeOffset
uint64_t parentNodeOffset
Definition: shared_variable.hpp:85
SharedMemoryVariable::SMV_TYPE_UNSIGNED
@ SMV_TYPE_UNSIGNED
Definition: shared_variable.hpp:45
SMV_String::operator=
char * operator=(const char *val) OME_ALWAYS_INLINE
Assignment operator into a shared memory string variable.
Definition: shared_variable.hpp:575
SharedMemoryVariableManager::attachExistingSegment
void attachExistingSegment(unsigned char *segment, size_t segmentLength)
Use an existing, already initialized, memory segment for variable storage.
Definition: shared_variable.cpp:375
SharedMemoryVariable::SMV_DISPLAY_EQUALS
@ SMV_DISPLAY_EQUALS
Definition: shared_variable.hpp:65
compiler_hints.h
Compiler-specific macros to provide performance-related hints.
OME_EXPECT_FALSE
#define OME_EXPECT_FALSE(expr)
Annotation macro for conditional expression expected to be false.
Definition: compiler_hints.h:540
SharedMemoryVariable::SharedMemoryVariable_Record::getPathPrefix
int getPathPrefix(char *bfr, uint_fast32_t bfrLen, unsigned char *base, bool isNative=true) const
Get parent path name of variable.
Definition: shared_variable.cpp:195
OME_ALWAYS_INLINE
#define OME_ALWAYS_INLINE
Tell the compiler to alway inline a function, regardless of optimization level.
Definition: compiler_hints.h:364
SharedMemoryVariable::getVariableManager
SharedMemoryVariableManager * getVariableManager() const
Definition: shared_variable.hpp:117
SharedBufferAllocRecord_32::blockLen
uint32_t blockLen
Definition: circular_bfr.hpp:106
SharedMemoryVariable::SMV_TYPE_UINT32
@ SMV_TYPE_UINT32
Definition: shared_variable.hpp:48
Sigma0
#define Sigma0(x)
Definition: sha256.cpp:44
SharedMemoryVariable::getFullName
uint_fast32_t getFullName(char *bfr, uint_fast32_t bfrLen) const
Get full path name of variable.
Definition: shared_variable.cpp:285
GET64_NATIVE
#define GET64_NATIVE(fieldName, isNative)
Definition: shared_variable.cpp:27
SharedMemoryVariable::SMV_TYPE_TINY_BINARY_STRING
@ SMV_TYPE_TINY_BINARY_STRING
Definition: shared_variable.hpp:55
SharedMemoryVariable::noteNowRegistered
virtual void noteNowRegistered(SharedMemoryVariable_Record *newArea)
Extension mechanism to allow derived classes to be informed when they are about to be assigned storag...
Definition: shared_variable.hpp:176
SMV_Numeric::operator/=
NUMTYPE & operator/=(const NUMTYPE arg) OME_ALWAYS_INLINE
Division operator for a numeric shared memory variable.
Definition: shared_variable.hpp:404
SharedMemoryVariable
Shared memory variable which allows statistics and operational controls to be exposed to other proces...
Definition: shared_variable.hpp:40
SMV_StandaloneNumeric::getAddress
NUMTYPE * getAddress() const OME_ALWAYS_INLINE
Get address of shared memory variable.
Definition: shared_variable.hpp:490
makeQualifiedFileName
uint_fast32_t makeQualifiedFileName(char *fileName, uint_fast32_t fileNameLen, const char *componentName, const char *suffix, const char *dirName, uint_fast32_t flags)
Create a filename and optionally qualify with the current date and process Id.
Definition: mapped_file.cpp:98
SharedMemoryVariableManager::offsetInSegment
size_t offsetInSegment(const SharedMemoryVariable::SharedMemoryVariable_Record *rec) const
Definition: shared_variable.hpp:292
SMV_Numeric::SMV_Numeric
SMV_Numeric(const char *varName, SharedMemoryVariableManager *mgr=&DEFAULT_sharedMemoryVariableManager) NONNULL_CLASS_PARAMETERS(2)
Definition: shared_variable.hpp:341
SharedBufferAllocRecord
SharedBufferAllocRecord_32 SharedBufferAllocRecord
Default SharedBufferAllocRecord.
Definition: circular_bfr.hpp:133
SharedMemoryVariable::SharedMemoryVariable_Record::varNameLength
uint16_t varNameLength
strlen() + 1; includes null in count
Definition: shared_variable.hpp:89
BufferRegion
Interface to a buffer region. This is an abstract class.
Definition: circular_bfr.hpp:177
FILENAME_WITH_EVERYTHING
#define FILENAME_WITH_EVERYTHING
Definition: mapped_file.h:38
length
int length(OMEthread *thread, OMEtype &result, const OMEtype &arg)
Definition: OILtypeFuncs.cpp:19
GET16_NATIVE
#define GET16_NATIVE(fieldName, isNative)
Definition: shared_variable.cpp:23
SharedMemoryVariable::variableManager
class SharedMemoryVariableManager * variableManager
Definition: shared_variable.hpp:105
SharedMemoryVariable::SMV_TYPE_UINT64
@ SMV_TYPE_UINT64
Definition: shared_variable.hpp:50
SharedMemoryVariable::SMV_TYPE_NONE
@ SMV_TYPE_NONE
Definition: shared_variable.hpp:44
SharedMemoryVariableManager::createSegment
static unsigned char * createSegment(const char *fileName, size_t *segmentLengthPtr, int initMode=MAP_FILE_INIT, const char *desiredMagicNumber=SMV_MAGIC_NUMBER)
Open a file and map it to a memory segment for variable storage.
Definition: shared_variable.cpp:342
SMV_Numeric::operator+=
NUMTYPE & operator+=(const NUMTYPE arg) OME_ALWAYS_INLINE
Addition operator for a numeric shared memory variable.
Definition: shared_variable.hpp:389
SMV_Numeric::operator++
NUMTYPE operator++(int) OME_ALWAYS_INLINE
Postfix increment operator for a numeric shared memory variable.
Definition: shared_variable.hpp:418
htonl
#define htonl(x)
Definition: tmp.o.cpp:3098
SharedMemoryVariableManager::regionBase
unsigned char * regionBase
Definition: shared_variable.hpp:199
SharedMemoryVariable::SharedMemoryVariable_Record::varName
char varName[12+sizeof(SharedBufferAllocRecord)]
variable name
Definition: shared_variable.hpp:90
SMV_StandaloneNumeric::operator--
NUMTYPE operator--(int) OME_ALWAYS_INLINE
Postfix decrement operator for a numeric shared memory variable.
Definition: shared_variable.hpp:540
SharedMemoryVariable::SMV_TYPE_TINY_STRING
@ SMV_TYPE_TINY_STRING
Definition: shared_variable.hpp:54
SharedMemoryVariable::_pad1
unsigned char _pad1[2]
Definition: shared_variable.hpp:110
SharedMemoryVariable::SMV_TYPE_LARGE
@ SMV_TYPE_LARGE
Definition: shared_variable.hpp:46
SharedMemoryVariable::SharedMemoryVariable_Record::i32
int32_t i32
Definition: shared_variable.hpp:79
SharedMemoryVariable::setName
int setName(const char *newName)
Set new variable name.
Definition: shared_variable.hpp:150
SharedBufferAllocRecord_64
Allocation record for chains in a 64-bit shared memory buffer.
Definition: circular_bfr.hpp:112
SMV_StandaloneString::operator=
char * operator=(const char *val) OME_ALWAYS_INLINE
Assignment operator into a shared memory string variable.
Definition: shared_variable.hpp:647
SharedMemoryVariable::SharedMemoryVariable
SharedMemoryVariable(class SharedMemoryVariableManager *mgr, const char *varName, int varType, size_t length)
Construct an shared memory variable and attach to the indicated manager for the collection of variabl...
Definition: shared_variable.cpp:230
SMV_String::SMV_String
SMV_String(const char *varName, size_t reservedLength, SharedMemoryVariableManager *mgr=&DEFAULT_sharedMemoryVariableManager) NONNULL_CLASS_PARAMETERS(2)
Definition: shared_variable.hpp:560
SharedMemoryVariable::SharedMemoryVariable_Record::formatAsText
char * formatAsText(char *bfr, uint_fast32_t bfrLen, uint_fast32_t displayMode, const char *pathPrefix=nullptr, bool isNative=true) const
Format variable into text buffer.
Definition: shared_variable.cpp:118
SharedMemoryVariableManager::regionLength
size_t regionLength
Definition: shared_variable.hpp:200
SMV_StandaloneNumeric::operator++
NUMTYPE operator++(int) OME_ALWAYS_INLINE
Postfix increment operator for a numeric shared memory variable.
Definition: shared_variable.hpp:534
Generated: Fri Jul 31 2020 18:19:15
Support Information