Giter VIP home page Giter VIP logo

onur-ulusoy / virtual-device-simulator Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 15.71 MB

Comprehensive simulation software for optimized testing and validation of hardware-dependent embedded systems in a Linux environment

License: MIT License

C++ 73.84% Python 21.00% CMake 5.09% RobotFramework 0.06%
device-driver device-management device-simulator embedded-linux embedded-software embedded-systems virtual-devices

virtual-device-simulator's Issues

Problem with parser

Some problems related to parser are found.

Configuring devices with long names leads to some issues.

  • Devices except GPIO only cannot be configured with relatively long names.
  • Trying to configure GPIO device with long names results in structural breakdown in JSON file.

image

Note/Why should the getInstance() method of a Singleton return a reference?

Problem Description

Singleton design pattern is implemented to child device classes successfully:

static GPIO_Device& getInstance(char* dev_name){
    static GPIO_Device instance(dev_name);
    return instance;
}

However it turns out to be a syntax error if it returns the actual object (namely call by value) instead of reference

static GPIO_Device getInstance(char* dev_name){
    static GPIO_Device instance(dev_name);
    return instance;
}

Problem Reason

When it called by value like below,

GPIO_Device gpio = GPIO_Device::getInstance(dev_name);    

Because it returns actual object and be assigned to a new object from GPIO_Device, copy constructor of the class is invoked and since the copy constructor of class is deleted it causes syntax error.

Fundamental Reason to Use Reference

In a Singleton pattern, the goal is to ensure that there is only one instance of a class. Returning a reference or pointer to that instance, instead of an object, helps ensure that there is only one instance of the class in the entire system. This allows other parts of the system to access the Singleton without accidentally creating new instances of it.

Calling it by value is against the nature of Singleton pattern cause it creates more than one object.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.