Hi guys, I have some class which uses boost singleton. It calls some function from own c++ library. This library is written in make file as dependence.
Now I have another singleton class and it should call first singleton class. After this code I got linkers error about undefined references for functions which are used in first singleton...
Please advise me the difference between two ways of declaration of java constructor
public class A{
private static A instance = new A();
public static A getInstance() { return instance;
}
public static void main(String[] args) {
A a= A.getInstance();
}
}
AND
public class B{
public B()...
Ok, I've got this singleton-like web class which uses session to maintain state. I initially thought I was going to have to manipulate the session variables on each "set" so that the new values were updated in the session. However I tried using it as-is, and somehow, it remembers state.
For example, if run this code on one page:
User...
I am trying to use a config file in my C# console application. I created the file within the project by going New --> Application Configuration File, and naming it myProjectName.config. My config file looks like this:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="SSDirectory" value="D:\Documents and Set...
Hi;
I have create a SinglestonClass in my code but i have a problem.
My variable are initialized in the -init method but when i call the singlestonClass these variable are re-initialize.
Can you help me for create a single initialization for my variable?
thanks.
@implementation SingletonController
@synthesize arrayPosition;
@synthesize...
Hello, I have such code:
// Non singleton
class MyLogManager
{
void write(message) {Ogre::LogManager::getSingletonPtr()->logMessage(message);}
}
class Utils : public singleton<Utils>
{
MyLogManager *handle;
MyLogManager& getHandle { return *handle; }
};
namespace someNamespace
{
MyLogManager &Log() { return Utils::get_mutab...
Hi guys, at this page:
http://torjo.com/tobias/index.html#boost_utility_singleton._usage I saw that boost has singleton class which gets second param: recreate instance if it's deleted (when we call the singleton). I can't find the implementation of this singleton in boost library. There is only singletons from serialization and pool. Wh...
Hi have a problem with singleton Class in iPhone app.
I have create a simple class for visualization of NSString value.
My problem is generate when i try to stamp a NSString in a textVIew.
I call my methods and the value of string in Singleton class is (invalid) (i have tested it with debug).
Can you help me with the code solution.
my c...
Hi,
someone can tell me why this is incorrect as a singleton pattern:
class preSingleton(object):
def __call__(self):
return self
singleton = preSingleton()
# singleton is actually the singleton
a = singleton()
b = singleton()
print a==b
a.var_in_a = 100
b.var_in_b = 'hello'
print a.var_in_b
print b.var_in_a
Edit:...
I need a singleton in my code. I implemented it in Java and it works well. The reason I did it, is to ensure that in a mulitple environment, there is only one instance of this class.
But now I want to test my Singleton object locally with a Unit test. For this reason I need to simulate another instance of this Singleton (the object that...
I am attempting to write a singleton role using Perl and Moose. I understand a MooseX::Singleton module is available but there is always resistance when requiring another CPAN module for our project. After trying this and having a little trouble I would like to understand WHY my method is not working. The singleton role I have written...
If I would like to have several static methods in my models so I can say User::get_registered_users() and have it do something like
public static function get_registered_users()
{
$sql = "SELECT * FROM `users` WHERE `is_registered` = 0";
$this->db->query($sql);
// etc...
}
Is it possible to access the $this->db object or c...
I've made a class that is a cross between a singleton (fifth version) and a (dependency injectable) factory. Call this a "Mono-Factory?" It works, and looks like this:
public static class Context
{
public static BaseLogger LogObject = null;
public static BaseLogger Log
{
get
{
return LogFactory...
module MyModule
def my_method; 'hello'; end
end
class MyClass
class << self
include MyModule
end
end
MyClass.my_method # => "hello
I'm unsure why "include MyModule" needs to be in the singleton class in order to be called using just MyClass.
Why can't I go:
X = MyClass.new
X.my_method
...
Friends
I have the following class that
class Singleton
{
private:
static Singleton *p_inst;
Singleton();
public:
static Singleton * instance()
{
if (!p_inst)
{
p_inst = new Singleton();
}
return p_inst;
}
};
Please do elaborate on precautions taken while implementing Sing...
Hello all,
If I have two classes "A" and "B", is it OK to derive B from A and then make B a Singleton?.
Thanks for your help.
...
We have the following class hierarchy:
public interface IManager {
object GetObject(int);
}
public class BaseManager : IManager ...
public class XManager : BaseManager {
...
public static XManager Instance;
}
public class YManager : BaseManager {
...
public static YManager Instance;
}
public static class ManagerFacade...
Early warning - code sample a little long...
I have a singleton NSMutableArray that can be accessed from anywhere within my application. I want to be able to reference the NSMutableArray from multiple NIB files but bind to UI elements via NSArrayController objects. Initial creation is not a problem. I can reference the singleton NSMutab...
Assume you divide up your systems in Value objects and Services objects (as suggested in "Growing Object-Oriented Software, Guided by Tests". Misko Hevery calls these "newables" and "injectables".
What happens when one of your value objects suddenly needs to access a service to implement it's methods?
Let's say you have a nice simple ...
What are the disadvantages of using a PHP database class as singleton?
...