2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Copyright 2010, Rene Gollent, rene@gollent.com.
4 * Distributed under the terms of the MIT License.
9 #include <util/DoublyLinkedList.h>
10 #include <util/OpenHashTable.h>
12 #include "FunctionInstance.h"
13 #include "LocatableFile.h"
19 class Function
: public BReferenceable
, private LocatableFile::Listener
{
27 // team must be locked to access the instances
28 FunctionInstance
* FirstInstance() const
29 { return fInstances
.Head(); }
30 FunctionInstance
* LastInstance() const
31 { return fInstances
.Tail(); }
32 const FunctionInstanceList
& Instances() const
33 { return fInstances
; }
35 const BString
& Name() const
36 { return FirstInstance()->Name(); }
37 const BString
& PrettyName() const
38 { return FirstInstance()->PrettyName(); }
39 LocatableFile
* SourceFile() const
40 { return FirstInstance()->SourceFile(); }
41 SourceLocation
GetSourceLocation() const
42 { return FirstInstance()
43 ->GetSourceLocation(); }
45 FunctionID
* GetFunctionID() const
46 { return FirstInstance()->GetFunctionID(); }
47 // returns a reference
49 // mutable attributes follow (locking required)
50 FileSourceCode
* GetSourceCode() const { return fSourceCode
; }
51 function_source_state
SourceCodeState() const
52 { return fSourceCodeState
; }
53 void SetSourceCode(FileSourceCode
* source
,
54 function_source_state state
);
56 void AddListener(Listener
* listener
);
57 void RemoveListener(Listener
* listener
);
60 void AddInstance(FunctionInstance
* instance
);
61 void RemoveInstance(FunctionInstance
* instance
);
63 void NotifySourceCodeChanged();
65 void LocatableFileChanged(LocatableFile
* file
);
68 typedef DoublyLinkedList
<Listener
> ListenerList
;
71 FunctionInstanceList fInstances
;
72 FileSourceCode
* fSourceCode
;
73 function_source_state fSourceCodeState
;
74 ListenerList fListeners
;
75 int32 fNotificationsDisabled
;
78 // BOpenHashTable support
83 class Function::Listener
: public DoublyLinkedListLinkImpl
<Listener
> {
87 virtual void FunctionSourceCodeChanged(Function
* function
);
88 // called with lock held