Add information to project file

Discussion about CodeLite development process and patches
jfouche
CodeLite Guru
Posts: 351
Joined: Mon Oct 20, 2008 7:26 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

Add information to project file

Post by jfouche »

Hi

I would like to know if there is a way to add information to a project file.
I looked at the ConfObject base class which look like a friend to plugin developpers. But I didn't find a way to add a new ConfObject to an existing project.
In fact, I just want to add optional features to a project file. So I would like something like :

Code: Select all

bool Project::AddConf(wxString sName, ConfObject* pConf);
ConfObject* Project::GetConf(wxString sName);
to get optional conf for a plugin (for example).
Do you think it is a good idea ? Actually, this is not possible because the ConfObject doesn't store any information. Maybe

Code: Select all

bool Project::AddConf(wxString sName, wxXmlNode* pConf);
wxXmlNode* Project::GetConf(wxString sName);
is better.
Moreover, what is the std::map<wxString, wxXmlNode*> m_vdCache; in Project class ?
--
Jérémie
Jérémie
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Add information to project file

Post by eranif »

Hi,

Can you give me an example of what would you like to add?

Eran
Make sure you have read the HOW TO POST thread
jfouche
CodeLite Guru
Posts: 351
Joined: Mon Oct 20, 2008 7:26 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

Re: Add information to project file

Post by jfouche »

I would like to add version informations about a project, something like :
<version-manager major="1" minor="2" release="6" build="243" status="release" />

Moreover, looking to the new events about building, maybe a new one can be interresting : wxEVT_BUILD_STARTING, sended (not posted) before build process.
--
Jérémie
Jérémie
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Add information to project file

Post by eranif »

Who is going to use this information? I mean: which class (Project class surely does not know about it) ? does it get inserted to the project during build?
If so how?

Eran
Make sure you have read the HOW TO POST thread
jfouche
CodeLite Guru
Posts: 351
Joined: Mon Oct 20, 2008 7:26 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

Re: Add information to project file

Post by jfouche »

Well, let me explain my idea

I think that adding project information can be usefull to plugin developpers.
Let's suppose I'm creating a version manager plugin (a supposition of course ;) ). I would like to store version information inside the project instead of managing my own configuration file. That way, the plugin can get information from the project easily with the plugin interface.
The Project class doesn't care about this information, but it can give this information to one which need it.
For example :

If I create a

Code: Select all

class VersionManagerConf : public ConfObject
{
    ...
    virtual wxXmlNode *ToXml() const;
    bool FromXml(wxXmlNode* pNodeVersion);
};

Code: Select all

ProjectPtr pProject = ...;
wxXmlNode* pNodeVersion = pProject->GetOptionalNode(wxT("version-manager"));
VersionManagerConf::FromXml(pNodeVersion);
...
pNodeVersion = VersionManagerConf::ToXml();
pProject->SetOptionalNode(pNodeVersion );
With this behaviour, you can extend CL projects capacities.
Is that clear for you ? What is your point of view ?
--
Jérémie
Jérémie
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Add information to project file

Post by eranif »

Ok I understand what you need.

Now that I know what you want, here is my suggestion:

I will extend Project class with the following API:

Code: Select all

bool Project::SetUserData(SerializeObject *obj, const wxString &name);
bool Project::GetUserData(SerializeObject *obj, const wxString &name);
Example of usage:
Reading data:

Code: Select all

MyData data;
wxString err_msg;
ProjectPtr proj = m_mgr->GetWorkspace()->FindProjectByName(wxT("MyProjectName"), err_msg);
proj->GetUserData(&data, wxT("SomeName"));


Writing data:

Code: Select all

MyData data;
data.SetValue(10);
data.SetNumber(5);
wxString err_msg;
ProjectPtr proj = m_mgr->GetWorkspace()->FindProjectByName(wxT("MyProjectName"), err_msg);
proj->SetUserData(&data, wxT("SomeName"));


Ofc, MyData is class deriving from SerializeObject and implements Serialize & DeSerialize methods (search for the code for "public SerializeObject" you will find many examples for it)

Will this be enough for your task?
Eran
Make sure you have read the HOW TO POST thread
jfouche
CodeLite Guru
Posts: 351
Joined: Mon Oct 20, 2008 7:26 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

Re: Add information to project file

Post by jfouche »

Great
Just remplace SerializeObject by SerializedObject ;)
--
Jérémie
Jérémie
jfouche
CodeLite Guru
Posts: 351
Joined: Mon Oct 20, 2008 7:26 pm
Genuine User: Yes
IDE Question: C++
Location: France
Contact:

Re: Add information to project file

Post by jfouche »

Everything is ready for me.
Just waiting for your implementation.
Do you want me to add this fonctionnality (if it is not to complicated... and if you didn't begin the job) ?
Jérémie
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Add information to project file

Post by eranif »

Implemented in SVN trunk.

Eran
Make sure you have read the HOW TO POST thread
Post Reply