16 Topics
|
|
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 … |
|
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 … |
|
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); } … |
|
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 |
|
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 … |
|
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 … |
|
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 … |
|
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; … |
|
# 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 … |
|
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 … |
|
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 … |
|
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 … |
|
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 … |
|
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 … |
|
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 … |
|
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 = … |
The End.