16 Topics

Member Avatar for
Member Avatar for vishnu balan

Please excuse me if this is silly.. I do want a clear picture of how we can use a singleton class?? I do read many answers here. But I didn't got anything clear. I need a simple program explaining **singleton class**. Please give me the explanation of each and every …

Member Avatar for tapananand
0
448
Member Avatar for Elixir42

Hi, When I initialise then access the `g_spMyLog` shared pointer, from within the `CSingleton::CreateLog` member function, it works ok. Accessing the SP from the static member function of `CSingleton::Create()` causes an `access violation` in the original project and an abort in this sample project displayed below. In the original project …

Member Avatar for Elixir42
0
526
Member Avatar for can-mohan

Guys, I need to write thread safe singleton class for my assignment. below is the code snippet for factory method in singleton class, I will appreciate if anyone is having suggestion for the same. *MySingleton * MySingleton::GetInstance() { if (m_pOnlyOneInstance == NULL) { pthread_mutex_lock(&mutex); m_pOnlyOneInstance = new MySingleton(); pthread_mutex_unlock(&mutex); } …

Member Avatar for mike_2000_17
0
4K
Member Avatar for cool_zephyr

how to make a bean application scoped so that it will persist as long as the web application is running??? and how can we access it in our controller?? thank you

Member Avatar for masijade
0
216
Member Avatar for klemme

Hi all, I would like to get my head around how I can create a singleton db pattern. What I have now works though, but as I know its not a singleton - My idea is this: * I would like a class that holds all config information and them …

Member Avatar for pritaeas
0
383
Member Avatar for adison.afonso

I have this Singleton class called ZombieLand that is supposed to represent a 2D array. This 2D array is getting constantly updated and populated by different instances of my MachineState struct, which contain x and y coordinates to help me navigate through the 2D array. #pragma once #include "singleton.h" #include …

Member Avatar for Moschops
0
235
Member Avatar for emilio

I'm having doubts about a need to use a singleton pattern in a web service. I'm building a web service that is acting as a server side for multiple clients. I was thinking about making my business logic classes a singleton classes but i'm having doubts because of the following …

Member Avatar for hericles
0
155
Member Avatar for Baduizm

I have this Singleton class: package com.CCharles.Singleton; import java.util.ArrayList; public enum Singleton{ INSTANCE; public void createList(){ ArrayList arrayList = new ArrayList(); for(int i=1;i<101;i++) { arrayList.add("Job "+i); } for(int i=1;i<101;i++) { System.out.println(arrayList.get(3)); } System.out.println("DONE"); } public void sayHello(){ System.out.println("Hello World"); } } and I am accessing Using: package com.CCharles.Singleton; import com.CCharles.Singleton.Singleton; …

Member Avatar for Baduizm
0
180
Member Avatar for DavidAntaramian

# Introduction to the Issue # I'm currently working on a piece of code that was put together by someone else on my team. All of his logic was in the `index.html` file, so I'm trying to factor it out into a modular library. Part of the reason is that …

Member Avatar for DavidAntaramian
0
233
Member Avatar for joshmac

I have a singleton class that I am revamping and need a little help with. I want to use the following syntax for my queries without having to declare a global object. Below is my current code: /** * The db database object * * @access private * @var object …

0
175
Member Avatar for joshmac

I am wanting to learn the singleton method, and I am having an issue with my code. I've been manipulating my own code for a few days now, but decided to use someone else's class to give it a try, and I am still coming up with nothing. Any help …

Member Avatar for joshmac
0
131
Member Avatar for sjcomp

Hello, I am using a singleton pattern, which works fine. But when I decided to have a singleton of a nested class that is privately declared. [CODE]class A : public CSingletonTmpl<A> { class B : public CSingletonTmpl<B> { }; }; A* CSingletonTmpl<A>::s_Singleton = NULL; A::B* CSingletonTmpl<A::B>::s_Singleton = NULL; [/CODE] The …

Member Avatar for madGambol
0
243
Member Avatar for Wej00

Just got back into C++ a couple months ago. Mainly, my plan is to get into game development. Hard field to get into, I know, but through school and a hopeful internship this summer, I will be able to fight my way in. I am currently learning SDL and I …

Member Avatar for Banfa
0
1K
Member Avatar for jakesee

Hi, I am playing around and trying to understand template singleton class and I accidentally created something that I am surprise it even runs. What I don't understand is when did Apple and Orange instances get created? Could you also comment on the good and bad of the Singleton class …

Member Avatar for jakesee
0
481
Member Avatar for pythopian

This is one simple way to emulate a singleton class on behalf of a normal class. (A singleton class is a class with at most one instance.) The implementation does not emulate a class 100% (for example it lacks the special attributes lile __dict__ or __bases__), but it should be …

2
229
Member Avatar for shashikant.v

public class OpenMenuListener implements ActionListener { public void actionPerformed(ActionEvent ev) { if(ev.getSource() == a) { f2 = new JFrame("shashikant verma"); p2 = new JPanel(); f2.getContentPane().add(p2); String str = "<html>"+"<h>"+"<P ALIGN = \"CENTER\">"+"<i>"+"<font size = \"10\">"+"<font color= \"#800080\">"+"CORRECT DEFINITION AND<br>"+"STRUCTURE OF FUNCTION y = f(x) "+"<br>"+"</i>"+"</h>"+"<P ALIGN = \"LEFT\">"+"<font size = …

Member Avatar for shashikant.v
0
213

The End.