Uniot Docs
  • Introduction
  • Guides
    • Getting Started
    • Uniot Badge
    • Device Network
  • Foundations
    • Edge Logic Deployment
  • General Concepts
    • Primitives
    • Scripting
  • Platform
    • Dashboard
    • Sandbox
      • Visual Editor
        • Special
        • Logic
        • Math
        • Loops
        • Text
        • Variables
        • Functions
        • Primitives
      • Logger
      • Emulator
      • Control Panel
  • Advanced
    • Uniot Core
      • Scheduler
        • TaskScheduler
        • IExecutor
        • ISchedulerConnectionKit
        • Task
        • SchedulerTask
      • AppKit
        • AppKit
        • LispDevice
        • LispPrimitives
        • TopDevice
      • CBORWrapper
        • CBORObject
        • COSE
        • COSEMessage
        • ICOSESigner
      • Date
        • Date
        • SimpleNTP
      • EventBus
        • EventBus
        • IEventBusConnectionKit
        • DataChannels
        • EventEmitter
        • EventListener
        • EventEntity
        • CallbackEventListener
      • Hardware
        • Button
      • LispWrapper
        • DefaultPrimitives
        • LispHelper
        • PrimitiveExpeditor
        • unLisp
      • MQTTWrapper
        • CallbackMQTTDevice
        • MQTTDevice
        • MQTTKit
        • MQTTPath
      • Network
        • ConfigCaptivePortal
        • NetworkController
        • NetworkScheduler
      • Register
        • GpioRegister
        • ObjectRegister
        • ObjectRegisterRecord
        • Register
        • RegisterManager
        • RegisterManagerProxy
      • Storage
        • CBORStorage
        • CrashStorage
        • Storage
        • WifiStorage
      • Utils
        • Array
        • Bytes
        • ClearQueue
        • IterableQueue
        • LimitedQueue
        • GlobalBufferMemoryManager
        • Map
        • Singleton
        • TypeId
      • Credentials
    • Uniot Lisp
      • Language Description
      • Embedding Instructions
  • API
    • MQTT Convention
Powered by GitBook
On this page
  1. Advanced
  2. Uniot Core
  3. Utils

TypeId

The TypeId utility provides a lightweight and efficient mechanism for runtime type identification and safe type casting without relying on traditional C++ Run-Time Type Information (RTTI).

Key Features:

  • Lightweight Type Identification: Uses unique pointers as type identifiers.

  • Interface for Type Retrieval: Provides a standardized way to retrieve an object's type identifier.

  • Safe Static Casting: Enables safe casting between base and derived classes based on type identifiers.

  • Template-Based Design: Leverages C++ templates for type-safe operations.

Methods:

  • template <class T> static inline type_id getTypeId() Generates a unique type identifier for the specified type T. This is achieved by using the address of a static pointer unique to each type.

  • template <typename T> static inline T* safeStaticCast(IWithType* obj) Safely casts an object of type IWithType* to T* if the object's type identifier matches that of type T. If the types do not match, the method logs a debug message and returns nullptr.

PreviousSingletonNextCredentials

Last updated 4 months ago