wrapper

What exactly does comparing Integers with == do?

狂风中的少年 提交于 2019-11-27 03:20:52
问题 EDIT: OK, OK, I misread. I'm not comparing an int to an Integer. Duly noted. My SCJP book says: When == is used to compare a primitive to a wrapper, the wrapper will be unwrapped and the comparison will be primitive to primitive. So you'd think this code would print true : Integer i1 = 1; //if this were int it'd be correct and behave as the book says. Integer i2 = new Integer(1); System.out.println(i1 == i2); but it prints false . Also, according to my book, this should print true : Integer

How to write a wrapper over functions and member functions that executes some code before and after the wrapped function?

青春壹個敷衍的年華 提交于 2019-11-27 02:23:07
问题 I'm trying to write some wrapper class or function that allows me to execute some code before and after the wrapped function. float foo(int x, float y) { return x * y; } BOOST_PYTHON_MODULE(test) { boost::python::def("foo", <somehow wrap "&foo">); } Ideally, the wrapper should be generic, working for functions and member functions alike, with any signature. More info: I'm looking for a simple way to release/re-acquire the GIL around my expensive C++ calls without having to manually write thin

Run a MATLAB script from python + pass args

瘦欲@ 提交于 2019-11-27 02:15:34
问题 I need to use the MATLAB Image Acquisition Toolbox to acquire few images from a video camera. MATLAB seems to be a nice solution because the Image Acquisition is easy and i have to do some image processing afterwards. I have searched for a long time but i still haven't found anything working. There were some tries: mlabwrap 1.1 - run a MATLAB-script: A MATLAB script like: vid = videoinput('testadaptor'); img = getsnapshot(vid); imwrite(img,'./image.png','png'); You can run this script by

A C++ iterator adapter which wraps and hides an inner iterator and converts the iterated type

假如想象 提交于 2019-11-27 01:37:52
问题 Having toyed with this I suspect it isn't remotely possible, but I thought I'd ask the experts. I have the following C++ code: class IInterface { virtual void SomeMethod() = 0; }; class Object { IInterface* GetInterface() { ... } }; class Container { private: struct Item { Object* pObject; [... other members ...] }; std::list<Item> m_items; }; I want to add these methods to Container: MagicIterator<IInterface*> Begin(); MagicIterator<IInterface*> End(); In order that callers can write:

What is the radix parameter in Java, and how does it work?

◇◆丶佛笑我妖孽 提交于 2019-11-27 01:35:19
I understand that radix for the function Integer.parseInt() is the base to convert the string into. Shouldn't 11 base 10 converted with a radix/base 16 be a B instead of 17 ? The following code prints 17 according to the textbook: public class Test { public static void main(String[] args) { System.out.println( Integer.parseInt("11", 16) ); } } When you perform the ParseInt operation with the radix, the 11 base 16 is parsed as 17, which is a simple value. It is then printed as radix 10. You want: System.out.println(Integer.toString(11, 16)); This takes the decimal value 11(not having a base at

Creating simple c++.net wrapper. Step-by-step

旧巷老猫 提交于 2019-11-27 00:09:23
I've a c++ project. I admit that I'm a complete ZERO in c++. But still I need to write a c++.net wrapper so I could work with an unmanaged c++ library using it. So what I have: 1) unmanaged project's header files. 2) unmanaged project's libraries (.dll's and .lib's) 3) an empty C++.NET project which I plan to use as a wrapper for my c# application How can I start? I don't even know how to set a reference to an unmanaged library. S.O.S. http://www.codeproject.com/KB/mcpp/quickcppcli.aspx#A8 This is general direction. You need to create C++/CLI Class Library project, add .NET class to it

When using wrapper, how to preserve class and method name for Log4Net to log?

五迷三道 提交于 2019-11-26 23:15:51
I need a Log4net wrapper - to be exposed to a number of different components in a large app. I obviously want to retain the class and method name when logging but I would keep away of passing down type etc to my wrapper. I had a look at this question which is very similar to mine, but it didn't help. I've seen it done in this other question with smt like the following: MethodBase methodBase = new StackTrace().GetFrame(1).GetMethod(); this.log.Debug(methodBase.Name + " : " + message); This is not ideal since it's not using the out-of-the-box Log4Net functionality. I'd like to get an idea of how

Wrapping unmanaged C++ with C++/CLI - a proper approach

岁酱吖の 提交于 2019-11-26 21:37:12
问题 as stated in the title, I want to have my old C++ library working in managed .NET. I think of two possibilities: 1) I might try to compile the library with /clr and try "It Just Works" approach. 2) I might write a managed wrapper to the unmanaged library. First of all, I want to have my library working FAST, as it was in unmanaged environment. Thus, I am not sure if the first approach will not cause a large decrease in performance. However, it seems to be faster to implement (not a right word

Simple way to get wrapper class type in Java

放肆的年华 提交于 2019-11-26 20:53:13
I have a piece of code where I need to pass the class of a field in a method. Because of the mechanics of my code I can only handle reference objects and not primitives. I want an easy way of determining if a Field 's type is primitive and swap it with the appropriate wrapper class. So in code what I do so far is something like this: Field f = getTheField(); // Dummy method that returns my Field Class<?> c = f.getType(); if (c == int.class) { c = Integer.class; } else if (c == float.class) { c = Float.class; } // etc myMethod(c); This works fine, except for the fact that I need to explicitly

what is difference between integer a = 5 and new Integer(5)?

不羁的心 提交于 2019-11-26 20:50:46
问题 if i write below code(in java): Integer a =new Integer(5); Integer b=new Integer(5); if(a==b){ System.out.println("In =="); } if(a.equals(b)){ System.out.println("In equals"); } My output is: "In equals" But if i change first and second line to -> Integer a =5; Integer b=5; then my o/p is: In == In equals So what is difference in creating a Integer object? How it gets created when we do Integer a =5 ? Does it mean that a and b object refer to same object, if i create Integer a=5 and creates