Page 1 of 1
Add information to project file
Posted: Sat Dec 20, 2008 5:24 pm
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
Re: Add information to project file
Posted: Sat Dec 20, 2008 6:10 pm
by eranif
Hi,
Can you give me an example of what would you like to add?
Eran
Re: Add information to project file
Posted: Sat Dec 20, 2008 6:27 pm
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
Re: Add information to project file
Posted: Sat Dec 20, 2008 6:38 pm
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
Re: Add information to project file
Posted: Sat Dec 20, 2008 6:55 pm
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
Re: Add information to project file
Posted: Sat Dec 20, 2008 7:36 pm
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
Re: Add information to project file
Posted: Sat Dec 20, 2008 7:55 pm
by jfouche
Great
Just remplace SerializeObject by SerializedObject
--
Jérémie
Re: Add information to project file
Posted: Sun Dec 21, 2008 3:54 am
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) ?
Re: Add information to project file
Posted: Sun Dec 21, 2008 1:26 pm
by eranif
Implemented in SVN trunk.
Eran