⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uuid.h

📁 这是广泛使用的通信开源项目,对于大容量,高并发的通讯要求完全能够胜任,他广泛可用于网络游戏医学图像网关的高qos要求.更详细的内容可阅读相应的材料
💻 H
字号:
// -*- C++ -*-
//=============================================================================
/**
 *  @file   UUID.h
 *
 *  UUID.h,v 1.4 2003/10/16 06:14:27 jwillemsen Exp
 *
 *  @author Huang-Ming Huang <hh1@cse.wustl.edu>
 */
//=============================================================================
#ifndef UUID_H
#define UUID_H
#include /**/ "ace/pre.h"

#include "ftrtevent_export.h"
#include "ace/OS.h"
#include "ace/SString.h"

#if defined(TAO_EXPORT_MACRO)
#undef TAO_EXPORT_MACRO
#endif
#define TAO_EXPORT_MACRO  FtRtEvent_Export

#if defined(TAO_EXPORT_NESTED_CLASSES)
#if defined(TAO_EXPORT_NESTED_MACRO)
#undef TAO_EXPORT_NESTED_MACRO
#endif /* defined (TAO_EXPORT_NESTED_MACRO) */
#define TAO_EXPORT_NESTED_MACRO FtRtEvent_Export
#endif /* TAO_EXPORT_NESTED_CLASSES */

/**
 * This is an implementation of Global Unique Identifier
 * which follows the document draft-leach-uuids-guids-01.txt. The
 * class layout is compatible with the binary representation of
 * UUID specified by that document. The default constructor
 * is used to create an new global unique id, not a NULL UUID.
 * This class does not use dynamic memory allocation and does
 * not throw any exception except to_string(ACE_CString&).
 */
class TAO_FtRtEvent_Export  UUID
{
  public:
    enum
    {
      BINRARY_LENGTH= 16,

      // the required length for the string representation including the termination '\0'
      STRING_LENGTH = 37
    };

    /* Construct an Global Unique Identifier. */
    UUID(void);

    /* This is used to create an uninitialized UUID. */
    UUID(int);

    /*
     * Construct an UUID from the binary represetation. If you want to avoid a memory
     * copy operation for this constructor. You can safely reinterpret_cast the 16
     * bytes buffer into the UUID object and use all the member functions provided in
     * this class except is_valid() which is only useful if a UUID object is
     * constructed from the string representation.
     */
    UUID(const unsigned char *buffer);

    /*
     * Construct an UUID from the string representation. Use is_valid() to test if the
     * construction is successful or not.
     */
    UUID(const char *);

    /* Construct an uuid from the string representation. */
    bool from_string(const char *string_rep);

    bool operator==(const UUID &other) const;
    bool operator!=(const UUID &other) const;

    /*
     * Test if the UUID is valid. Used after constructing an UUID from an string
     * representation. This is done by testing whether the time_hi and time_mid fields
     * of the timestamp are 0. By current time, those two field shouldn't be 0 at all.
     */
    bool is_valid(void) const;

    /*
     * convert to a string representation the buffer size provided must be at least
     * STRING_LENGTH
     */
    void to_string(char *string_rep) const;

    void to_string(ACE_CString &string) const;

    /*
     * convert to a string representation the buffer size provided must be at least
     * BINRARY_LENGTH
     */
    void to_binary(unsigned char *binary_rep) const;

    /* create an UUID in the specified buffer */
    static void create(unsigned char *buffer);
  private:
    union
    {
      struct
      {
        ACE_UINT32  low;
        ACE_UINT32  hi;
      } timestamp;
      unsigned char uuid[BINRARY_LENGTH];
    } rep_;
};

#if defined(__ACE_INLINE__)
#include "UUID.inl"
#endif /* __ACE_INLINE__ */

#include /**/ "ace/post.h"
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -