• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 164
  • Last Modified:

adding properties to an object

hey all,
Im working with an indy nttp client, and I made it multi-threaded ( connecting )
and I create the objects dynamically, but I was wondering if its possible to create additional properties for each nttp object
I want to store more information within each individual object, like add the property how many such and such that the normal indy client doesnt hold.
DO I have to adjust the indy clients code directly and recompile the source code for TidNNTP, or can I just add to it indirectly from within my own app?

indirectly using my own class and be able to reference my class from within the indy object:

type
  TNNTPCustProps = class
    private
      FGroupCount: integer;
      procedure SetGroupCount(const Value: Integer);
    public
      // --- THE CUstom idNTTP PROPERTIES -----
      property GroupCount: integer read FGroupCount write SetGroupCount;
  end;

var
  NNTPprops: TNNTPCustProps;

implementation

{ TCustomNNTP Properties }

procedure TNNTPCustProps .SetGroupCount(const Value: integer);
begin
  FGroupCount := Value;
end;

then access this property from within the indy nntp object like so:

var
  IdNNTP1 : TIdNNTP;
begin
  IdNNTP1 := TIdNNTP1.create(self);
  IdNNTP1 .GroupCount := 0;
  // etc..............


thanx in advance







0
LMuadDIb
Asked:
LMuadDIb
  • 3
1 Solution
 
mikelittlewoodCommented:
Do what you are doing now, but make your object of class TidNNTP.
This means you inherit from it but you can add your owns properties to it like you are doing.
0
 
mikelittlewoodCommented:
type
  TNNTPCustProps = class(TidNNTP)
    private
      FGroupCount: integer;
      procedure SetGroupCount(const Value: Integer);
    public
      // --- THE CUstom idNTTP PROPERTIES -----
      property GroupCount: integer read FGroupCount write SetGroupCount;
  end;

var
  NNTPprops: TNNTPCustProps;

implementation

{ TCustomNNTP Properties }

procedure TNNTPCustProps .SetGroupCount(const Value: integer);
begin
  FGroupCount := Value;
end;

then access this property from within the indy nntp object like so:

var
  IdNNTP1 : TIdNNTP;
begin
  IdNNTP1 := TIdNNTP1.create(self);
  IdNNTP1 .GroupCount := 0;
  // etc..............
0
 
paulb1989Commented:
I think the above is slightly wrong, use:

var
  IdNNTP1 : TNNTPCustProps;
begin
  IdNNTP1 := TNNTPCustProps.create(self);
  IdNNTP1 .GroupCount := 0;
  // etc..............
0
 
mikelittlewoodCommented:
Missed his creation of his object.
Paulb1989 is correct with how to create your object.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now