Link to home
Start Free TrialLog in
Avatar of LMuadDIb
LMuadDIbFlag for United States of America

asked on

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







Avatar of Mike Littlewood
Mike Littlewood
Flag of United Kingdom of Great Britain and Northern Ireland image

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.
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..............
ASKER CERTIFIED SOLUTION
Avatar of paulb1989
paulb1989

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Missed his creation of his object.
Paulb1989 is correct with how to create your object.