Is There a Proper 'Ownership-In-A-Package' for 'Handles' Available

Is there a proper 'ownership-in-a-package' for 'handles' available?

std::experimental::unique_resource

Using std::unique_ptr for Windows HANDLEs

The implementation of unique_ptr checks for the presence of a ::pointer type on the deleter. If the deleter has a ::pointer type then this type is used as the pointer typedef on the unique_ptr. Otherwise a pointer to the first template argument is used.

According to cppreference.com, the unique_ptr::pointer type is defined as

std::remove_reference<D>::type::pointer if that type exists, otherwise T*

In Go 1.18 strings.Title() is deprecated. What to use now? And how?

As mentioned in documentation strings.Title is deprecated and you should use cases.Title instead.

Deprecated: The rule Title uses for word boundaries does not handle
Unicode punctuation properly. Use golang.org/x/text/cases instead.

Here is an example code of how to use it as from two perspectives:

// Straightforward approach
caser := cases.Title(language.BrazilianPortuguese)
titleStr := caser.String(str)

// Transformer interface aware approach
src := []byte(s)
dest := []byte(s) // dest can also be `dest := src`
caser := cases.Title(language.BrazilianPortuguese)
_, _, err := caser.Transform(dest, src, true)

Make sure to take a look on the transform.Transformer.Transform and cases.Caser in order to understand what each parameter and return values mean, as well as the tool's limitations. For example:

A Caser may be stateful and should therefore not be shared between
goroutines.

Regarding what language to use, you should be aware of their difference in the results, besides that, you should be fine with any choice. Here is a copy from 煎鱼's summary on the differences that cleared it for me:

Go Playground: https://go.dev/play/p/xp59r1BkC9L

func main() {
src := []string{
"hello world!",
"i with dot",
"'n ijsberg",
"here comes O'Brian",
}
for _, c := range []cases.Caser{
cases.Lower(language.Und),
cases.Upper(language.Turkish),
cases.Title(language.Dutch),
cases.Title(language.Und, cases.NoLower),
} {
fmt.Println()
for _, s := range src {
fmt.Println(c.String(s))
}
}
}

With the following output

hello world!
i with dot
'n ijsberg
here comes o'brian

HELLO WORLD!
İ WİTH DOT
'N İJSBERG
HERE COMES O'BRİAN

Hello World!
I With Dot
'n IJsberg
Here Comes O'brian

Hello World!
I With Dot
'N Ijsberg
Here Comes O'Brian

Who is the owner of a relationship?

To be honest, the definition of terms in Superstructures is still very poor.

Looking closer it's even worse (citing from ptc 13-09-05).

Relationships (p. 15)

A Relationship is an Element that specifies some kind of relationship between other Elements. Descendants of Relationship provide semantics appropriate to the concept they represent.

Connector (p. 235)

A Connector specifies links that enables communication between two or more instances. In contrast to Associations, which specify links between any instance of the associated Classifiers, Connectors specify links between instances playing the connected parts only.

I wasn't aware that they made a difference between both. Appears to be quite picky.

Association (p. 206)

An Association classifies a set of tuples representing links between typed instances. An AssociationClass is both an Association and a Class.

No mentioning of Relationship as being a parent.

Now seeking for the truth about owner

owner (p. 37)

/owner : Element [0..1]{union} (opposite Element::ownedElement) The Element that owns this Element.

mustBeOwned (a bit down)

mustBeOwned() : Boolean
The query mustBeOwned() indicates whether Elements of this type must have an owner. Subclasses of Element that do not require an owner must override this operation.

So here one is stuck unless reading to

Association (p 209)

Ownership of Association ends by an associated Classifier may be indicated graphically by a small filled circle, which for brevity we will term a dot. The dot is to be drawn integral to the graphic path of the line, at the point where it meets the Classifier, inserted between the end of the line and the side of the node representing the Classifier. The diameter of the dot shall not exceed half the height of the aggregation diamond, and shall be larger than the width of the line. This avoids visual confusion with the filled diamond notation while ensuring that it can be distinguished from the line. The dot shows that the model includes a Property of the type represented by the Classifier touched by the dot. This Property is owned by the Classifier at the other end. In such a case it is normal to suppress the Property from the attributes compartment of the owning Classifier.

Answer?

Most likely (!) connectors do not have the mustBeOwned constraint and can be owned in which case you will see the dot that has been introduced with 2.5. Else they are probably not owned.

SSIS Element cannot be found in a collection (but I have them all listed!)

Ohhh.........man. It's amazing how you can stare at this stuff and miss something stupid, for hours.

strFooter was missing in the listing.

ALL SET NOW. Sincere thanks to those who looked and commented. Eric, thanks, I'll remember that as sometimes I will probably need to use C insatead of VB (haven't yet but will).

React eslint error missing in props validation

the problem is in flow annotation in handleClick, i removed this and works fine
thanks @alik

Why use a owner window in MessageBox.Show?

A message box is a modal form, which means that its parent window is disabled until the message box is dismissed.

If a Show() overload is called that does not take an owner identifier, then a parent form is usually chosen automatically. I can't find anything in the documentation that describes how that form is chosen, but my experience is that if the message box is displayed inside the GUI thread (i.e., the main thread, or message pump thread), then the active window for that thread is chosen as the parent.

Other threads may create message boxes with no parent form. This could be a bad situation, because it could sit behind the active window, and the user will not even know it is there until they close the program. To avoid this, you could pass the handle of the application's main window to the Show method, which will disable that window for the duration of the message box.


ADDED: I've been thinking about this and now I'm not so sure. The snippet from reflector that you gave below makes me think that maybe the thread doesn't matter. (I did say that I couldn't find anything in the documentation!)

I'd have to go back and look at the code to make sure, but I think the message boxes that I used to lose behind the main form may have actually been custom message box forms, in which case my experience is faulty, and you never ever have to supply a parent form parameter.

Sorry for the confusion.

My recommendation now is to never supply this parameter unless you need something other than the active window to be the main form.



Related Topics



Leave a reply



Submit