Questions tagged [wrapper]

A wrapper is an OOP technique where an object encapsulates (wraps) another object, resource (dynamically allocated memory, OS file/widow handle, socket, thread mutex, etc) or a set of subroutines, hiding/protecting it and providing another (possibly easier to use) interface. When using this tag on implementation heavy questions - tag the code language the implementation is written in.

A Wrapper is an Object which contains another data type, Object, resources, or subroutines for the purpose of encapsulation. The corresponding class of that Wrapper is the wrapper class.

Often when we refer to a wrapper class we often refer to a primitive wrapper class, where instances of that class encapsulate a primitive type.

Many object-oriented languages, such as Java, differentiate between primitive types (such as char) and Objects (such as String), for example that primitive values are passed on by value and are the simplest data types, whereas Objects are passed on by reference and that it includes their own fields and methods. The names of primitive data types are also usually keywords, as opposed to Objects.

In some cases, you may need an instance of a wrapper class for these primitives to perform boxing, treat these primitives as Objects due to OOP reasons, converting a primitive to another Object type, or when using an otherwise primitive value when polymorphism is required. The name of the corresponding primitive wrapper class for a given primitive data type are written in full and follow naming conventions for classes (such as beginning with an uppercase in Java).

Java wrapper classes:

Java offers these wrapper classes which you can use without importing anything. Note that their names begin with an uppercase, and are written in full.

  • Boolean for booleans
  • Character for char
  • Integer for int
  • Long for 64-bit int
  • Double for boudle
  • Byte for byte
  • Short for short
  • Float for float

Tags related to wrapper operations:

Link to Wikipedia page

3619 questions
1
vote
1 answer

Trouble understanding how props are accessed in HOC

I'm trying to understand this basic example of HOC : function ppHOC(WrappedComponent) { return class PP extends React.Component { constructor(props) { super(props) this.state = { name: '' } this.onNameChange =…
1
vote
0 answers

C++ wrapper class for eigen (linear algebra library)

I am writing a class wrapper for a linear algebra class - eigen for now - because I do not want to expose my code to the internals of the library (or its design) and was wondering if there is a way to write an interface without destroying the…
Konrad
  • 11
  • 2
1
vote
1 answer

fullcalendar react wrapper scheduler passing events

I'm trying to use fullcalendar-react-wrapper-scheduler in my project. The documentation shows an example of passing events into the FullCalendar component, however it does not show how to pass in resources. I'm attempting to pass in "resources" by…
1
vote
1 answer

Creating CSV file as an object

I have got a robust script which gets, parse and uses some data from .csv file. To run the script I can use .\script.ps1 -d data_file.csv The thing is I cannot interfere into script itself that is why i need to create some kind of a wrapper which…
mil.troj
  • 13
  • 3
1
vote
1 answer

Timing of a C++ function wrapped with cython

I do not really know how to ask this question, but I will try to be as clear as possible. I am timing a C++ function call from python. The C++ function is wrapped with cython. I am currently timing the python call of the cython function and I get…
Romzie
  • 457
  • 4
  • 11
1
vote
1 answer

opencv 3.3 python linemod: how to add templates

today it try to use the linemod algorithm which is part of OpenCV. In an earlier C++ project I already use linemod and it works like it is described in the documentation, but this time I try to use the Python API. Here my approach: import…
user3851038
  • 85
  • 1
  • 8
1
vote
1 answer

Python Ctypes: Loading C++ DLL - "module not found" or "function 'fn_123' not found"

I'm trying to load AND call functions from an already compiled (not by me) C++ DLL file. I'm faced with two problematic scenarios: Loading DLL by using CDLL(): from ctypes import * __path_aa_Fn_dll__ = r'C:\user\aacad_2017\aa_Functions.dll' # DLL…
ilbi
  • 51
  • 5
1
vote
0 answers

Using a wrapper to prevent elements from moving around?

I'm very new to HTML/CSS, and am working on a website for my band. The problem I'm running into is that when I resize the window, the text gets jumbled up and the logo shrinks. I've already researched this problem, but haven't had any luck so far.…
Mr. Cat
  • 27
  • 6
1
vote
2 answers

Function wrappers inside class using decorators

I have a class which interacts with a database and so there are repetitive actions (establish session, commit, close session) before and after each member method of the class. As follows: class UserDatabaseManager(object): DEFAULT_DB_PATH =…
Katie
  • 918
  • 1
  • 5
  • 18
1
vote
1 answer

How should I properly use parent class methods and the keyword extends in typescript?

I have two classes, one a parent, and one a child, that implement types to define their expected functionality. That is below here. export abstract class BaseLogService implements IBaseLogService { static $inject: string[] = ['$http'] …
Chris
  • 443
  • 5
  • 25
1
vote
2 answers

Dynamically wrap the contents of a C# method at run-time instantiation

I have a base class with some virtual functions public class ABaseClass { public virtual void DoAThing() { print("print this base"); } } I have another class that inherits from the base class as below. public class AChildClass…
Shabloinker
  • 361
  • 2
  • 9
1
vote
1 answer

Wrapper for tr with Vue.js DataTable

I have a table with 2 in it. I need to wrap this 2 and do the v-for in the wrap. But the v-for on break the datatable. Actual code : …
ZeRoX
  • 53
  • 5
1
vote
1 answer

How can a class generate a callback function, that changes according to a class attribute?

I have this situation: module1.py: class AudioEngine: def __init__(self): self.liverecording = False def getaudiocallback(self): def audiocallback(in_data, frame_count, time_info, status): # these 4 parameters are…
Basj
  • 41,386
  • 99
  • 383
  • 673
1
vote
1 answer

C++ Compiler Reports Ambiguous Function Call When Using Bool Wrapper Class

I have a delima. I'm using wrapper classes for native types, however, when using the wrapper types as function arguments, the implicit conversion for char pointer to bool keeps causing the compiler to issue an ambiguous function call error: class…
SirKM
  • 60
  • 5
1
vote
2 answers

Using Facade Like a wrapper

I usually see some people used facade like this. public class FooFacade { Foo foo; public boolean isFunny(param1, param2) { IsFunnyInput isFunnyInput = new IsFunnyInput(param1, param2); return foo.isFunny(isFunnyInput); …
1 2 3
99
100