If you use LabVIEW classes in your application, examples, POCs, etc., you may have been wondering how to implement a singleton object.
What is a singleton? Singletons are known in the LabVIEW world as action engines, functional globals with methods, and under a few other names. Basically it is a set of data with associated functions, and you ever only one instance of this object in your application. A functional global (non-reentrant subVI), with uninitialized shift registers (USR)) to store the data and multiple cases to implement the different functions, is the most common example of a singleton in LabVIEW. Using OOP you can easily create a class which contains the same data and functions, however, by default a class will not limit the application to only one instance (object) of the class.
There recently was a good discussion on LAVA about singletons, including a good reference example of a singleton implemented as a LV class provided by LV R&D.
http://lavag.org/topic/11513-singleton-design-pattern/page__view__findpost__p__70428
One application of a singleton object may be a database interface in an application where many different components or other objects access the same database. Typically you only want one object or component touching the database to avoid conflicts, race conditions, etc. A database access class with a singleton object is a good solution for this type of application.
developing embedded systems and industrial control applications.
Showing posts with label oop. Show all posts
Showing posts with label oop. Show all posts
Tuesday, January 19, 2010
Friday, February 27, 2009
Welcome to my Life on the Wire.
I'm not sure yet what aspect of LabVIEW life I want to document and comment on, but I figure I need to start where I am and then decide where I am going depending on the road ahead, my feelings of the day and possibly the weather out there in cyper space. Welcome and feel free to send me comments, feedback, and topic ideas that you're interested in.
I think my first direction will be to discuss my lack of knowledge of LVOOP and experience in learning/using LVOOP to implement a flexible and customizable configuration tool for LV applications (code name 'xCE'). I'm starting with the basic idea of the Tag Configuration Editor (TCE) and looking to expand it to handle more complex configurations (hierarchy, collections, etc.) and in addition enabling the developer to easily customize and configure their configuration editor by defining new item types using LVOOP. TCE for any configuration task => xCE.
I'm not sure yet what aspect of LabVIEW life I want to document and comment on, but I figure I need to start where I am and then decide where I am going depending on the road ahead, my feelings of the day and possibly the weather out there in cyper space. Welcome and feel free to send me comments, feedback, and topic ideas that you're interested in.
I think my first direction will be to discuss my lack of knowledge of LVOOP and experience in learning/using LVOOP to implement a flexible and customizable configuration tool for LV applications (code name 'xCE'). I'm starting with the basic idea of the Tag Configuration Editor (TCE) and looking to expand it to handle more complex configurations (hierarchy, collections, etc.) and in addition enabling the developer to easily customize and configure their configuration editor by defining new item types using LVOOP. TCE for any configuration task => xCE.
Subscribe to:
Posts (Atom)