'How to describe a member function with "void*" as input in UML?

I'm new to UML, how to describe the following class with a member function that takes void*?

// used on linux
#include <unistd.h>

class LinuxReadWrapper
{
  public:
    LinuxReadWrapper(){/** Ctor */}
    ~LinuxReadWrapper(){/** Dtor */}

    ssize_t WrapperRead(void* buf)
    {
      return read(fd, buf, cnt);
    }

  private:
    int fd{-1};
    size_t cnt{0};
};

Thanks!



Solution 1:[1]

Although Red Bear's answer is a very practical one, it is worth to remind that:

  • UML build-in primitive types are limited to: Integer, String, Boolean, UnlimitedNatural and Real
  • UML types can be extended with the help of a profile. Such a profile can extend the UML standard metamodel and introduce new «datatype». A profile is a package that you can import in all the models that need it. It is common to have a programming-language profile for the programming-language specific types.
  • A pointer (e.g. my_type *) requires extra-care, because in general the pointer is not the type relevant for the the UML model, since the pointer's purpose is to implements an association with an plain object (e.g. of class my_type).
  • In this regard a void* pointer is somewhat special, since it points to an object of unknown type, so keeping it as it is in the model is an understandable approach.

The good news is that datatypes are a standard feature of UML. So in any decent modelling tool you should find a way. For example:

  • Enterprise Architect lets you add new datatypes to your project
  • StarUML lets you add new datatypes to your project
  • Visual Pardigm lets you add new datatypes to the project configuration
  • Many tools just allow you to use whatever type you want. Visual Studio for example just lets you use any data type and will add unrecognized types to the model.
  • etc...

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Christophe