construction

Thread safe lazy contruction of a singleton in C++

Is there a way to implement a singleton object in C++ that is: Lazily constructed in a thread safe manner (two threads might simultaneously be the first user of the singleton - it should still only be constructed once). Doesn't rely on static variables being constructed beforehand (so the singleton object is itself safe to use during t...

Emptying a C++ object

Often I add an Empty method to my C++ objects to clear the internal state using code similar to the following. class Foo { private: int n_; std::string str_; public: Foo() : n_(1234), str_("Hello, world!") { } void Empty() { *this = Foo(); } }; This seems to be better than duplicating code in t...

Is Object constructor called when creating an array in Java?

In Java, an array IS AN Object. My question is... is an Object constructor called when new arrays is being created? We would like to use this fact to instrument Object constructor with some extra bytecode which checks length of array being constructed. Would that work? ...

Programmatic HTMLDocument generation using Java

Hi, Does anyone know how to generate an HTMLDocument object programmatically in Java without resorting to generating a String externally and then using HTMLEditorKit#read to parse it? Two reasons I ask: Firstly my HTML generation routine needs to be very fast and I assume that parsing a string into an internal model is more costly than...

How to specify which columns can be returned from linq to sql query

I'm trying to only return a few columns from a linq to sql query but if I do, it throws the exception: Explicit construction of entity type 'InVision.Data.Employee' in query is not allowed Here's the code: return db.Employees.Select(e => new Employee() { EmployeeID = e.EmployeeID, FirstName = e.FirstName, LastName = e....

Construct object from LINQ using same fields of another query

Hello all That's example SQL create view v_join as select m.* , d.oneDetail from master m, detail d where m.key = d.key LINQ var view = from v in dc.v_join select new { Master = ???? /// that is an issue, how can I construct the objects using same fields but from another query, Detail = v.oneDetail }; foreach (var entry i...

When is an object in Javascript constructed?

Consider the following Javascript function (1): function setData(domElement) { domElement.myDataProperty = { 'suppose': 'this', 'object': 'is', 'static': 'and', 'pretty': 'big' }; }; Now what I don't like about this function is that the exact same object is created every time the function is called. Since the objec...

Why isn't there a Windows.Forms like program for C++ (is there?)

I don't think there is any program like VS Windows.Forms for C++. Now I know that "Windows.Forms" are in themselves a C# "thing", but it eludes me why no one has put together a similar graphical construction interface for C++ Windows GUIs. Am I just not aware of it/them? Should I try to make one (that'd be a challenge, for me anyway, bu...

C++ referring to an object being constructed.

In C++ I have a reference to an object that wants to point back to its owner, but I can't set the pointer during the containing class' construction because its not done constructing. So I'm trying to do something like this: class A { public: A() : b(this) {} private: B b; }; class B { public: B(A* _a) : a(_a) ...

accessing third-party ruby library module in code? is this the right way on windows?

I needed a little script to read data out of windows-style .ini files. Searching my windows machine I found inifile.rb in this path: C:\ruby\lib\ruby\site_ruby\1.8\vr\contrib\ it seems unnatural to add this path directly to my rubylib path as this will mean any other special units I want will need to be added. so in my code I wrote...

Under Construction page For Website Without Redirect

Hi! I wanted to know if there is some way to change something simple, such as a htaccess file, a js file, or a php file, and then all of the webpages on my site will show an under construction page. I do not really care all that much if the user has to be redirected, but I want the origonal url of the page to be displayed in the address ...

How does a view work (MVC)?

I'm working on a web-app without a framework right now, and I'm trying to structure it as a MVC app. The problem is, there are some technical aspects of MVC apps that escape me. Primarily, how should a view be build? I'd like to use a markup language like eRuby or #haml, but I don't know how exactly they work and how to implement them ...

Hard-coding Fonts in DotNET

I've run into problems on numerous occasions of users not having one of the Windows Core fonts installed on their machine (Courier New, Comic Sans MS, Arial for example). Whenever I try to construct one of these it throws an error rather than falling back onto a related, or really, any other font. What is the best way to construct a Fon...

Best way to represent Bit Arrays in C#??

Hi all, I am currently building a DHCPMessage class in c#. RFC is available here : http://www.faqs.org/rfcs/rfc2131.html Pseudo public object DHCPMessage { bool[8] op; bool[8] htype; bool[8] hlen; bool[8] hops; bool[32] xid; bool[16] secs; bool[16] flags; bool[32] ciaddr; bool[32] yiaddr; bool[...

Rails Under Construction Page

Hi Everyone, I know this may seem trivial to some, other won't see the point, however - for me this would be great: I am trying to work out how to quickly and efficiently commit updates to my Rails app, switch to an under construction style page while I restart the rails app and then test the changes, then when I am happy, switch back...

The ** idiom in C++ for object construction

In a lot of C++ API'S (COM-based ones spring to mind) that make something for you, the pointer to the object that is constructed is usually required as a ** pointer (and the function will construct and init it for you) You usually see signatures like: HRESULT createAnObject( int howbig, Object **objectYouWantMeToInitialize ) ; -- bu...

draw smooth surface from 3D points via vtk

Hello every body. I have a set/cloud of 3D points of human face and want to draw a smoother surface using vtk. I have tried Delaunay triangulation but the result is not good. Thanks. ...

Cross source file template instantiation and use

I have a class with several template member functions that I would like to distribute among several source files to speed up compilation times. (The templates are implementation details and are not intended to be used outside the class, hence their definition in sources not headers.) How would I go about splitting up these templates in ...

jquery widget, _create or _init

Some jquery plugin extend widget use _create method, while others use _init method, can someone explain the differences between the two? Also any guidance on when it is better to extend widget or directly extend jquery.fn? ...