Resource Monitor is First-Class Object as described by Snowflake documentation ; i didn't understand what first class mean,what exactly first-class object mean?
"First class object" simply means that your object exists independently.
According to the answer here (What are "first class" objects?), a first class object is an object that can be "dynamically created, destroyed, [...]"
Related
I am learning qemu and qom recently. I am perplexed when I meet the conception of ObjectClass and Object. I already understand that ObjectClass stands for class while Object means instance of class. However, what I want to know is What kind of information should store in ObjectClass and what's going on in Object.
As far as I am concerned, like C++ or Java, Object just the same as what's define in Class and be used in real logic. In this case, Class seems like a template which produce Object the real be used.
In qemu, everything seems different. We define these two in two struct, and they have different properties, which leads to separation of Class and Object. Does it means I can use one ObjectClass to produce many Object that differ with each other? And secondly, why should I do this? Are there any advantages of this pattern? In detail, what's the role ObjectClass and Object plays in qemu respectively? And what about their relationship? If I want to design a new device, What should I do in initialization of MyObjectClass and MyObject?
What's more, I notice that qemu will initialize every ObjectClass by TypeImpl, which is initialized by TypeInfo defined by developer.
TypeInfo => ModuleEntry => TypeImpl => ObjectClass => Object
Of course they do different things. TypeInfo converts to ModuleEntry before main function is executed(__attribute__((constructor))), which contains initial functions of ObjectClass and Object. Why we need this mechanism? On the other words, what if we just create ObjectClass instead of create TypeImpl and create ObjectClass after that? Any advantages?
This is part of QEMU's object model (QOM), which is documented in the developer section of the documentation. You should read that, and also look through include/qom/object.h for more details of the object model.
In QOM, for any class there is one class struct -- for the base Object type the class struct is ObjectClass. There are then multiple objects created at runtime, each of which is a struct Object. This applies also for subtypes of Object, like DeviceState, whose class struct is DeviceClass. The class struct holds fields which are common to every instance of that object type, notably including the function pointers which are the equivalent of methods. The object struct holds all the fields which are per-instance. Because each Object contains a pointer to the corresponding ObjectClass, you can always get from a pointer to an instance of an object to its class information.
Because we're implementing an object-oriented model in C, we have to have everything be explicit -- in C++ and Java, because the object model is part of the language the compiler can sort out under the hood a lot of the things QOM has to manage manually with class structs and object structs and so on.
More generally, if your aim is "write a new device" I would recommend that you do not spend any time looking into the internals of the QOM implementation. Instead you should look at how other devices similar to yours are implemented and at what the patterns of code are that they use to declare and use a new device type.
first issue:
in GObject I confuse that whether the instance object of subclass deriving from parent class inherits properties of parent class or not?
second issue:
in GObject g_object_class_install_properties function adds properties into itself class in class initializer function,but in effect these properties for each instance object of class have a copy.in other words, each instance object of class have a copy of these properties.
in addition, I read GObject code snippet.
at below code in Gobject.c fileļ¼
class->set_property = g_object_do_set_property;
class->get_property = g_object_do_get_property;
firstly when are above functions called?
secondly if subclass derive from parent class subclass overrides these motheds (set_property and get_property),then if g_object_new creats new subclass instance and set properties value the set_property callback function is only called , whether after calling subclass set_property it calls set_property method of parent class or not ?
I don't know that after only calling at a time set_property of subclass,Is set_property method of parent class called at a time?
if you know these issues,please spend you time for anwsering my isses, thank you in advance very much.
If you have not yet seen the GNOME Developer site, it has several pages of useful information relevant to the questions you ask. The links pointed to below contain very simple example code, followed by very detailed descriptions of what happens in the code. The example pages I have cited (and linked) below address your questions specifically, but much more content on the topic is available in surrounding pages.
First issue:
Derivable types can be subclassed further, and their class and
instance structures form part of the public API which must not be
changed if API stability is cared about. They are declared using
G_DECLARE_DERIVABLE_TYPE:
See examples here:
G_DECLARE_DERIVABLE_TYPE()
Second issue:
generic get/set mechanism for object properties. When an object is
instantiated, the object's class_init handler should be used to
register the object's properties with
g_object_class_install_properties.
See examples here: Object properties
I believe your specific question:
when are above functions called?
is addressed is great detail in these, and surrounding paragraphs in the Object Properties link above:
If the user's GValue had been set to a valid value,
g_object_set_property would have proceeded with calling the object's
set_property class method. Here, since our implementation of Foo did
override this method, execution would jump to foo_set_property after
having retrieved from the GParamSpec the param_id [4] which had been
stored by g_object_class_install_property.
Once the property has been set by the object's set_property class
method, execution returns to g_object_set_property which makes sure
that the "notify" signal is emitted on the object's instance with the
changed property as parameter unless notifications were frozen by
g_object_freeze_notify.
I've read through the doc and spec of JSON-LD and JSON-LD-API (and might as well have missed something).
I found that the local context of an object node may be composed by defining "#context: [.., .., ...]" as an array of multiple context definitions (some of which may be inlined, others may be external references). I also found that referencing an "external context" assumes the corresponding IRI reference resolves to a JSON-LD document with an expected #context definition in its root object node, which is to be used in place of the original reference to the "external context".
My question is: Is it valid (or reasonable, or implied), that the referenced #context in the remote JSON-LD document may also be composite (just like an ordinary local #context), or is a referenced external context restricted to being a definite context entity (i.e. either a local XOR external definition, i.e. NOT an array of many context definitions)?
(This question is probably directed towards the authors of the JSON-LD standard).
A remote context is not restricted in any way which means that it can contain references to other contexts.
As the title says, when should we declare a property of type DbSet for an entity, General Guidelines ?
There are no general guidelines. Instance of DbSet<YourEntity> is your access point to loading and persisting entities of a given type. If you don't expose the property on your context type you can still create it on the fly by using dbContext.Set<YourEntity>().
The only difference between exposing and not exposing the property is in entity discovery during defining the model. When EF is first use it builds "the model" for defined entities. Entities are discovered through:
Mappings explicitly defined on DbModelBuilder instance
Configuration types explicitly registered in DbModelBuilder instance
DbSet<> properties defined in context type
Types referenced by already discovered entities
So if you don't use DbSet<> properties you must tell EF about your entities with other methods.
I'm using HtmlPage.RegisterCreateableType method to call some C# code from javascript. In MSDN documentation they say:
Registers a managed type as available for creation from JavaScript
code, through the Content.services.createObject and
Content.services.createManagedObject helper methods
There isn't more explanation about these two methods and I don't know what are the differences. Anybody knows differences between these methods?
Tons of information on both of these methods here.
createObject
Description: Given a registered scriptAlias, this method returns a
script wrapper for the corresponding managed type.
createManagedObject
Description: Given the typeName of the target .NET Framework type,
this method creates a default instance of the type by using either a
parameterless constructor (for reference types) or the default value
representation (for value types).
Basically, you use createObject if you have a script alias to an object. If you just need to create an instance of a type of object you use createManagedObject.